A peer-to-peer chat and file sharing system using UDP.
The system consists of three main components:
graph TD
subgraph "Public Internet"
RS[Relay Server]
end
subgraph "Local Network A"
CA[Client A] --- WA[Web UI A]
end
subgraph "Local Network B"
CB[Client B] --- WB[Web UI B]
end
CA -.->|Register/Discover| RS
CB -.->|Register/Discover| RS
CA <==>|UDP Hole Punching| CB
CA <==>|P2P Chat / File Share| CB
- Relay Server: A public UDP server that coordinates NAT traversal and peer discovery.
- Client: A Go backend that handles identity management, P2P networking, messaging, and file transfers. It also serves a local web interface.
- Web UI: A React-based frontend that communicates with the client via WebSockets and REST.
.
├── client/ # Go Client source code
├── server/ # Relay Server source code
├── protocol/ # Shared P2P communication protocols
├── web/ # React Frontend source code
make allThis command will:
- Build the frontend assets (
web/dist). - Build the Go client, embedding the frontend assets into the binary.
- Build the Go server.
- Place all binaries in the
bin/directory.
./bin/server
# Listens on 0.0.0.0:8080 by defaultOpen two terminal windows and start two clients:
Client A:
./bin/client -name Alice -api 8081 -udp 3001Client B:
./bin/client -name Bob -api 8082 -udp 3002- Open the UI:
http://localhost:8081(Client A) andhttp://localhost:8082(Client B). - Connect peers.
- Start chatting or sharing files!