Simple p2p cli chat application.
I wrote this application to be able to easily share links and files on the cli with others on the network, but I wanted it to be more comfortable than netcat.
Please do keep in mind, that I wrote this application solely for personal use, that means:
- I don't plan on adding any more documentation except the already extensive comments
- no tests (!)
- the application does clean up after unexpected exceptions (usually network issues), but it does not provide explanations to the user or try to recover
- automatically connects to other peers
- redirects stdin (or file contents) to them
- redirects their messages to stdout
That's it.
- encryption
- authentication
- Oftentimes a bug causes input supplied via pipes or the
-f
flag to be lost
A short outline of what happens when starting the application:
- A random tcp port is opened to listen for incoming connections
- for each new connection, stdin is duplicated and redirected to the connected peer
- all incoming messages are redirected to stdout
- The application starts listening for UDP pings in a multicast group
- if a ping is received, it answers with an identification string and its tcp port via an UDP pong
- A ping is sent to a multicast group, where other peers are listening
- other peers answer to the ping
- the application connects to every discovered peer in the same manner as in 1.
You'll need the Haskell development tool stack.
stack build
For chatting, just run it.
stack exec -- chat
You can use pipes to send the output of other programs to chat peers:
(Currently a bug causes input supplied via pipes or the --file
flag to be lost)
cat someFile | stack exec -- chat
You can directly read from files instead of stdin:
stack exec -- chat --file myFile
- you can get additional debug information by using the
-d
flag
The latest Linux binary can be obtained from here. Packages for Arch Linux are also available:
curl -O "https://raw.githubusercontent.com/ahbnr/chat/master/archlinux/bin/PKGBUILD"
makepkg -sri PKGBUILD
curl -O "https://raw.githubusercontent.com/ahbnr/chat/master/archlinux/git/PKGBUILD"
makepkg -sri PKGBUILD
# Download source
git clone --depth=1 https://github.com/ahbnr/chat.git
cd chat
# Download stack build tool
curl -sSLO https://get.haskellstack.org/stable/linux-x86_64.tar.gz
tar -xf linux-x86_64.tar.gz
cp stack-*/stack .
rm -rf stack-*
# Building
./stack build
./stack exec chat