Expand description
NAT Hole Punching Protocol (QUIC-only)
This protocol enables direct connections between peers behind NATs by using existing connected peers as signaling relays. It is restricted to QUIC because QUICβs single-socket design allows the dialer and listener to share the same port, which is essential for NAT traversal. NAT hole punching protocol (QUIC-only)
- Peer A wants to connect to peer C (both behind NATs)
- A finds mutual peer B connected to both
- A sends
HolepunchRequestto B - B sends
HolepunchConnectto both A and C with synchronized timing - A and C simultaneously connect to each otherβs observed addresses
StructsΒ§
- Holepunch
Connect - Instruction to attempt a holepunch connection
- Holepunch
Request - Request a peer to relay a holepunch
- Holepunch
Result - Result of a holepunch attempt
- Protocol
Holepunch - Used
Nonce π
ConstantsΒ§
- ALLOWED_
SCHEME π - CONNECT_
VALIDITY_ πMS - Maximum time window in ms for a connection instruction to be valid.
- COORDINATION_
DELAY_ πMS - Delay before simultaneous connection attempt in ms
- HOLEPUNCH_
MAX_ BYTES - HOLEPUNCH_
METERING - MAX_
CLOCK_ πSKEW_ MS - Maximum clock skew allowed between peers in ms
- MAX_
PENDING_ πPER_ PEER - Maximum pending holepunch requests per peer IP
- NONCE_
EXPIRY_ πSECS - Nonce expiry time for replay protection
- PROTO_
NAME π
StaticsΒ§
- INITIATOR_
NONCES π - Tracks nonces for active
initiate_punch()calls.