#stun-turn #p2p #nat #turn

rift-nat

NAT traversal, STUN, and TURN support for Rift P2P

5 releases

0.1.4 Feb 11, 2026
0.1.3 Feb 11, 2026
0.1.2 Feb 11, 2026
0.1.1 Feb 10, 2026
0.1.0 Feb 10, 2026

#13 in #stun-turn


Used in 4 crates (3 directly)

Apache-2.0 OR MIT

84KB
1.5K SLoC

rift-nat

riftd

crates.io docs.rs License DOI

NAT traversal, STUN, and TURN support for the riftd P2P protocol.


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.

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.

Dependencies

~13–28MB
~296K SLoC