How xlmnxp/qanah works
Qanah is a peer-to-peer VPN that turns WireGuard-style configuration into encrypted IP tunnels carried over WebRTC data channels. The principal workflow parses peer configuration, prepares a TUN interface, derives keys, negotiates peer connections through automatic MQTT or manual signaling, then routes packets directly or through a single relay hop. The excerpts show the main orchestration and packet-routing responsibilities; some setup and keepalive details are documented in the README rather than visible in sampled code.
Main entry points: main.rs VPN orchestration · tunnel.rs Peer routing table · crypto.rs Packet encryption · peer.rs Peer connection
Components 16
Configuration and setup
- VPN orchestration
src/main.rs - WireGuard config
src/config.rs - TUN interface
src/tunnel.rs
Keys and security
- Key derivation
src/crypto.rs - Packet encryption
src/crypto.rs
Peer connectivity
- Peer connection
src/peer.rs - WebRTC and ICE
- Signaling exchange
src/signaling.rs - MQTT broker
Tunnel traffic
- Peer routing table
src/tunnel.rs - Packet forwarding
src/tunnel.rs - WebRTC data channel
- NAT keepalive
src/main.rs
Other components
- VPN operator
- Host network
- Manual SDP exchange
Connections 24
- VPN operator → VPN orchestration: starts VPN
README.md - VPN orchestration → WireGuard config: loads config
src/main.rs - VPN orchestration → TUN interface: creates interface
src/main.rs - TUN interface → Host network: configures routes
README.md - VPN orchestration → Key derivation: derives keys
src/main.rs - Key derivation → Packet encryption: provides keys
src/crypto.rs - VPN orchestration → Peer connection: starts connections
src/main.rs - Peer connection → WebRTC and ICE: negotiates ICE
src/peer.rs - VPN orchestration → Signaling exchange: exchanges SDP
src/main.rs - Signaling exchange → MQTT broker: publishes SDP
README.md - VPN operator → Manual SDP exchange: copies SDP
README.md - VPN orchestration → Manual SDP exchange: offers or answers
README.md - Signaling exchange → Packet encryption: encrypts signaling
src/signaling.rs - Peer connection → WebRTC data channel: opens channel
src/peer.rs - TUN interface → Packet forwarding: reads packets
README.md - Packet forwarding → Peer routing table: routes packets
src/tunnel.rs - Peer routing table → Packet encryption: encrypts outbound
src/tunnel.rs - Peer routing table → WebRTC data channel: sends packets
src/tunnel.rs - WebRTC data channel → Packet forwarding: delivers packets
- Packet forwarding → Packet encryption: decrypts inbound
src/tunnel.rs - Packet forwarding → TUN interface: writes packets
src/tunnel.rs - VPN orchestration → NAT keepalive: manages keepalive
README.md - NAT keepalive → WebRTC data channel: sends keepalives
README.md - Peer routing table → Peer routing table: relays one hop
src/tunnel.rs