Expand description
TURN for the Sans-I/O WebRTC stack.
Traversal Using Relays around NAT (RFC 5766) with IPv6 support (RFC 6156). TURN is ICE’s fallback: when no direct path between two peers can be found, each relays its media through a server, which allocates a public address on their behalf.
§Structure
client— the Sans-I/O client: allocate a relayed address, create permissions, bind channels, and send or receive through the allocation. It owns no sockets.proto— the TURN-specific STUN attributes and methods (ALLOCATE,CREATE-PERMISSION,CHANNEL-BIND,XOR-RELAYED-ADDRESS, ChannelData framing), built onrtc-stun.
§Example
A client is configured with the server to allocate from and the long-term credentials to
authenticate with; driving it is then a matter of feeding it datagrams and polling for
Events:
use rtc_turn::client::ClientConfig;
use shared::TransportProtocol;
let config = ClientConfig {
turn_serv_addr: "turn.example.com:3478".to_owned(),
local_addr: "0.0.0.0:0".parse().unwrap(),
transport_protocol: TransportProtocol::UDP,
username: "user".to_owned(),
password: "pass".to_owned(),
realm: "example.com".to_owned(),
stun_serv_addr: String::new(), // optional: only for Binding requests
software: String::new(),
rto_in_ms: 0, // 0 selects the default retransmission timeout
};
assert_eq!(config.turn_serv_addr, "turn.example.com:3478");Most applications do not depend on this crate directly — rtc-ice gathers relay
candidates through it, and the rtc crate drives that.