rift-nat 0.1.4

NAT traversal, STUN, and TURN support for Rift P2P
Documentation

rift-nat


Part of the riftd project — serverless P2P voice + text chat over UDP.

What's in this crate?

rift-nat handles the hard problem of connecting peers behind NATs:

  • STUN Client — Discover your public IP and port (server-reflexive address)
  • TURN Client — Relay fallback when direct connection fails
  • NAT Detection — Identify NAT type (full cone, restricted, symmetric)
  • Hole Punching — Coordinated UDP hole punch attempts
  • ICE-lite — Simplified ICE candidate gathering

Usage

use rift_nat::{StunClient, NatProbe};

// Discover reflexive address via STUN
let stun = StunClient::new("stun.l.google.com:19302").await?;
let reflexive = stun.binding_request().await?;
println!("Public address: {}", reflexive);

// Probe NAT type
let nat_type = NatProbe::detect().await?;

TURN Setup

For self-hosted TURN relay, see TURN_GUIDE.md.

Related Crates

Crate Description
rift-rndzv Rendezvous coordination
rift-mesh Mesh networking (uses NAT traversal)

Citation

If you use riftd in academic work, please cite:

de Beer, R. (2026). Predictive Rendezvous: Time–Intent–Deterministic Peer Coordination Without Infrastructure. Zenodo. https://doi.org/10.5281/zenodo.18528430

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.