A simple rendezvous protocol implementation to help with NAT traversal or hole punching.
The main idea is straightforward: using a rendezvous server to observe peers' addresses and forward connection requests. When both peers send packets to each other, the NAT device or firewall rule then allows the traffic through.
use rndz::tcp::Client;
let c1 = Client::new(rndz_server_addr, "c1", None)?;
c1.listen()?;
while let Ok(stream) = c1.accept()? {
// Handle stream
}
use rndz::tcp::Client;
let c2 = Client::new(rndz_server_addr, "c2", None)?;
let stream = c2.connect("c1")?;
use rndz::udp::Client;
let c1 = Client::new(rndz_server_addr, "c1", None)?;
c1.listen()?;
c1.as_socket().recv_from(...)?
use rndz::udp::Client;
let c2 = Client::new(rndz_server_addr, "c2", None)?;
c2.connect("c1")?;
c2.as_socket().send(b'hello')?
$ rndz server --listen-addr 0.0.0.0:8888 # To allow clients to communicate with IPv6, use [::]:8888
$ rndz client --id c1 --server-addr rndz_server:8888
$ rndz client --id c2 --server-addr rndz_server:8888 --remote-peer c1
Due to the reliance on socket options SO_REUSEADDR
and SO_REUSEPORT
behavior, and the connected
UDP socket, it does not work on all platforms.
Tests pass on Linux; however, udp::Client::listen()
does not work on Windows.
- quic-tun: A QUIC-based port forward.
- minivtun-rs: A UDP-based VPN.
- rndz-go: Golang implementation of rndz.