High-Performance Serverless P2P Messaging
GhostLink is a decentralized chat app. It connects users directly without using central servers. Direct communication reduces latency and improves performance.
| Version | Status | Description |
|---|---|---|
| v1.0 | Legacy | First release. Plaintext messaging with reliable UDP transport. |
| v1.1 | Stable | Added Security. End-to-End Encryption (E2EE) using X25519 and ChaCha20-Poly1305 encryption. |
GhostLink separates the Web Interface from the P2P core. These parts communicate through thread-safe state. Version 1.1 also adds a secure handshake layer before starting a stream.
Steps:
- Initialization: The app starts an HTTP web server and a UDP listener.
- Discovery: The UDP layer uses a STUN server to get the public IP and open a connection.
- Secure Handshake: Peers exchange public keys over UDP.
- Transport: A reliable, encrypted stream is created for data transfer.
- End-to-End Encryption: Uses X25519 keys and HKDF for secure communication.
- Forward Secrecy: Creates session keys for each connection.
- Identity Verification: Shows SAS codes so users can verify connections.
- Reliable UDP: Uses KCP for fast, reliable transport.
- NAT Traversal: Connects through networks using STUN.
- Real-Time Updates: Sends live updates to the web UI using SSE.
GhostLink can be configured using a configuration file, command-line arguments, or both. Configuration is applied in the following order of precedence (highest to lowest):
- Command-line arguments (highest priority)
- Configuration file (
config.toml) - Built-in defaults (lowest priority)
# UDP port for client connections (0 = auto-assign)
client_port = 0
# STUN server for NAT traversal
stun_server = "stun.l.google.com:19302"
# STUN verifier for NAT type detection
stun_verifier = "stun4.l.google.com:19302"
# HTTP web server port
web_port = 8080
# Handshake timeout in seconds
handshake_timeout_secs = 30
# NAT keep-alive interval in seconds
punch_hole_secs = 15
# Disconnect timeout in milliseconds
disconnect_timeout_ms = 500
# Encryption mode: "chacha20poly1305" or "aes256gcm"
encryption_mode = "chacha20poly1305"You can override any configuration option using command-line arguments:
# Show all available options
cargo run --release -- --help
# Use a custom configuration file
cargo run --release -- --config /path/to/config.toml
# Override specific settings
cargo run --release -- --web-port 9000 --client-port 5000
# Combine config file with overrides
cargo run --release -- --config myconfig.toml --encryption-mode aes256gcm| Option | Short | Description | Default |
|---|---|---|---|
--config |
-c |
Path to configuration file | config.toml |
--client-port |
-p |
UDP port for client connections (0 = auto) | 0 |
--stun-server |
-s |
STUN server address | stun.l.google.com:19302 |
--stun-verifier |
-v |
STUN verifier address | stun4.l.google.com:19302 |
--web-port |
-w |
HTTP web server port | 8080 |
--handshake-timeout-secs |
-t |
Handshake timeout in seconds | 30 |
--punch-hole-secs |
-k |
NAT keep-alive interval in seconds | 15 |
--disconnect-timeout-ms |
-d |
Disconnect timeout in milliseconds | 500 |
--encryption-mode |
-e |
Encryption mode (chacha20poly1305 or aes256gcm) | chacha20poly1305 |
| Component | Technology | Purpose |
|---|---|---|
| Runtime | Tokio | Manages I/O and tasks. |
| Transport | Tokio KCP | Handles reliable UDP communication. |
| Cryptography | RustCrypto | Provides secure key and encryption functions. |
| Web Framework | Axum | HTTP REST API and real-time event streaming. |
| State | Arc/RwLock | Ensures thread-safe state management. |
| Discovery | STUN | Resolves public IPs and opens connections. |
STATUS: Encrypted
GhostLink v1.1 uses encryption to secure data:
- Key Exchange: Uses X25519 elliptic-curve.
- Ciphers: Uses ChaCha20-Poly1305 or AES-256-GCM.
- Verification: Users can check fingerprints to avoid interception.
Private keys are only stored in memory and never sent or saved.
Install the latest versions of Rust and Cargo.
- Clone the repo:
git clone https://github.com/pushkar-gr/ghostlink.git cd ghostlink - Build and run:
cargo run --release
- Create a connection:
- Open
http://localhost:8080in your browser. - Copy your public IP.
- Share it with a peer.
- Set an optional alias.
- Press Establish Link.
- Verify the fingerprint matches your peerβs.
- Open
- Fork the repository.
- Create a branch:
git checkout -b feature/example-feature
- Make and commit your changes:
git commit -m "Explain the feature" - Push the branch:
git push origin feature/example-feature
- Open a Pull Request.
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.
Start chatting today! π»
