A simple CLI chat tool in Go that connects two people over WebSockets.
Both people need each other's one-time key to connect. Once matched, the server pipes messages between the two and deletes the keys from memory. If either person leaves, the connection drops for both, and the keys can't be reused.
- You run the server on a machine with a public IP or domain.
- Two people run the client.
- Each client generates a random one-time key.
- You send your key to your friend, and they send theirs to you (via Signal, SMS, whatever).
- Both of you paste the other person's key into your terminal.
- The server matches the pair, bridges the connection, and forgets the keys.
- Hit
Ctrl+Cto quit. When one person leaves, the session is gone. To chat again, start over with new keys.
git clone https://github.com/ph01001000/server-client.git
cd server-client
go build -o server server.go
go build -o client client.goBy default, the server generates a temporary self-signed certificate so it can serve wss:// right away without setup:
./server -addr :8443If you have real SSL certificates (like from Let's Encrypt), pass them with flags:
./server -addr :8443 -cert cert.pem -key key.pem$ ./client -srv wss://your-server.com:8443/pipe or just ./client
your key: xyz
peer key: abc
connected.
=====================================
> hey
------------------------------$ ./client -srv wss://your-server.com:8443/pipe
your key: abc
peer key: xyz
connected.
=====================================
Connection:
hey
------------------------------
> - No storage: There is no database or file storage. The server only holds a SHA-256 hash of the key pair in memory while waiting for the second person to join. As soon as both are connected, that hash is deleted.
- Two-way lock: If someone steals your key, they still can't connect to you because they don't know your peer's key. Both sides must specify each other.
- Timeout: If you start the client and the other person doesn't show up within 2 minutes, the server drops the wait slot and you have to generate a new key.
- In-transit encryption: Everything runs over TLS 1.3 (
wss://). Keys are sent in request headers rather than URL query parameters so they don't end up in reverse proxy access logs.
MIT