Skip to content

About

A server and client for a secure one on one connection and chat

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Introduction

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.


How it works

  1. You run the server on a machine with a public IP or domain.
  2. Two people run the client.
  3. Each client generates a random one-time key.
  4. You send your key to your friend, and they send theirs to you (via Signal, SMS, whatever).
  5. Both of you paste the other person's key into your terminal.
  6. The server matches the pair, bridges the connection, and forgets the keys.
  7. Hit Ctrl+C to quit. When one person leaves, the session is gone. To chat again, start over with new keys.

Build

git clone https://github.com/ph01001000/server-client.git
cd server-client

go build -o server server.go
go build -o client client.go

Running the server

By default, the server generates a temporary self-signed certificate so it can serve wss:// right away without setup:

./server -addr :8443

If you have real SSL certificates (like from Let's Encrypt), pass them with flags:

./server -addr :8443 -cert cert.pem -key key.pem

Connecting

Person A:

$ ./client -srv wss://your-server.com:8443/pipe or just ./client
your key: xyz
peer key: abc

connected.
=====================================
> hey
------------------------------

Person B:

$ ./client -srv wss://your-server.com:8443/pipe
your key: abc
peer key: xyz

connected.
=====================================
Connection:
hey
------------------------------
> 

A few details

  • 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.

License

MIT

About

A server and client for a secure one on one connection and chat

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages