rtci-turn
Sans-I/O TURN client (RFC 8656, RFC 6062 TCP allocations) for WebRTC. 25 public modules, 80 items at 0.5.0.
cargo add [email protected] · crates.io · docs.rs · README on GitHub· MSRV 1.89
README
A TURN client: allocations for UDP relayed addresses of either family or both, permissions, channels, refreshes, the long-term credential mechanism, and TCP allocations (Connect, ConnectionAttempt, a data connection per peer). There is no TURN server.
Specifications
- RFC 8656, Traversal Using Relays around NAT (TURN)
- RFC 6062, TURN extensions for TCP allocations
- RFC 8489, STUN, as TURN uses it
Clause-by-clause status, with the test that proves each clause: rfc8656, rfc6062.
Use
client::Client runs allocations against a server; the root crate (rtci) uses it to gather relayed candidates over UDP, TCP, TLS and DTLS, so most applications only configure a turn: / turns: URL on the peer connection.
Sans-I/O
Datagrams in, datagrams out, deadlines polled: the transport to the server (UDP socket, TCP or TLS connection) belongs to the caller. The crate does no I/O and reads no clock: every call that depends on time takes an Instant from the caller.
Licence
Licensed under either of the MIT licence or the Apache License, Version 2.0, at your option.
This crate is part of the rtci workspace, which descends from webrtc-rs/rtc and is developed independently; FORK.md lists what it carries over upstream. Upstream's licence and copyright notices are retained.
rtci_turn
TURN for the Sans-I/O WebRTC stack.
- mod
clientThe Sans-I/O TURN client. - mod
protoThe TURN-specific STUN attributes, methods and ChannelData framing. - mod
restTime-limited TURN credentials of the "TURN REST API" (draft-uberti-behave-turn-rest-00, section 2.2; coturn'suse-auth-secret/static-auth-secret): the username is the credential's expiry as a Unix timestamp, optionally followed by a separator and an application-chosen id (1735689600:alice), and the password is base64(HMAC(secret, username)). A server that checks the timestamp on every … - use
crypto
rtci_turn::client
The Sans-I/O TURN client.
- mod
bindingChannel bindings, which replace the 36-byte Data indication header with a 4-byte one. - mod
data_connectionThe data connections of a TCP allocation (RFC 6062). - mod
permissionPer-peer send permissions, which a relay requires before it will forward to an address. - mod
relayA live allocation on the server, and sending or receiving through it. - mod
transactionOutstanding request tracking, with the RFC's retransmission schedule. - struct
AllocateOptionsfromallocation::AllocateOptionsWhat an Allocate request asks for beyond a UDP relayed address (RFC 8656 §7.1). - struct
CachedCredentialThe realm, nonce and password algorithm a TURN server accepted an authenticated request with, and the user name and password they were used with: what RFC 8489 §9.2.3.2 has a client cache "for subsequent communications with the server". A later client to the same server with the same login starts its Allocate with them (Client::use_cached_credential) instead of an unauthenticated request … - struct
ClientClient is a STUN client - struct
ClientConfigClientConfig is a bag of config parameters for Client. - struct
ErrorResponsefromerror::ErrorResponseAn error response from the server: its code and what a client acts on with it. - struct
RetransmissionConfigThe retransmission timer of the client's requests (RFC 8489 §6.2), the onertci-stunhas (stun::timer). The default is the RFC's. - enum
EventWhat the client produces in response to inbound datagrams and elapsed time. - enum
RelayTransportfromallocation::RelayTransportWhat an allocation relays to and from peers: the REQUESTED-TRANSPORT of its Allocate. - enum
RequestErrorfromerror::RequestErrorWhy a TURN request did not do what it asked. - type
PeerAddrThe address of a remote peer the client exchanges data with through the relay. - type
ReflexiveAddrThe client's own address as seen by the server — its server-reflexive address. - type
RelayedAddrThe public address the TURN server allocated on this client's behalf. - const
DEFAULT_SOFTWAREThe defaultSOFTWAREof the TURN client's requests (ClientConfig::software). - use
TryAlternatefromstun::alternate::TryAlternate
rtci_turn::client::binding
Channel bindings, which replace the 36-byte Data indication header with a 4-byte one.
No public items at its top level.
rtci_turn::client::data_connection
The data connections of a TCP allocation (RFC 6062).
- struct
DataConnectionOne client data connection of a TCP allocation: a second TCP (or TLS) connection to the TURN server that, once bound, carries one peer's byte stream as it is (RFC 6062 §4.3 to §4.5). - enum
DataConnectionEventWhat aDataConnectionreports. - const
CONNECTION_BIND_TIMEOUTHow long the ConnectionBind may go unanswered. The server gives a new peer connection 30 seconds to be bound and then closes it (RFC 6062 §5.2, §5.3), so nothing can answer later.
rtci_turn::client::permission
Per-peer send permissions, which a relay requires before it will forward to an address.
No public items at its top level.
rtci_turn::client::relay
A live allocation on the server, and sending or receiving through it.
- struct
RelayA borrowed handle to one live allocation on the TURN server.
rtci_turn::client::transaction
Outstanding request tracking, with the RFC's retransmission schedule.
No public items at its top level.
rtci_turn::proto
The TURN-specific STUN attributes, methods and ChannelData framing.
- mod
addfamilyTheADDITIONAL-ADDRESS-FAMILYattribute, for asking for an IPv6 relayed address beside the IPv4 one. - mod
addrAddress helpers and the five-tuple that identifies an allocation. - mod
addrerrorTheADDRESS-ERROR-CODEattribute, which says why one of two address families was not allocated. - mod
chandataChannelData messages — the compact 4-byte framing for relayed data. - mod
channumTheCHANNEL-NUMBERattribute. - mod
connidTheCONNECTION-IDattribute of TCP allocations (RFC 6062), which names a peer's TCP connection. - mod
dataTheDATAattribute, which carries relayed payloads in Send/Data indications. - mod
dontfragTheDONT-FRAGMENTattribute, asking the server to set DF on relayed packets. - mod
evenportTheEVEN-PORTattribute, requesting an even relayed port (for RTP/RTCP pairs). - mod
icmpTheICMPattribute, which reports an ICMP error a relayed datagram met. - mod
lifetimeTheLIFETIMEattribute, which sets and reports allocation expiry. - mod
peeraddrTheXOR-PEER-ADDRESSattribute, naming the peer in permission and data messages. - mod
relayaddrTheXOR-RELAYED-ADDRESSattribute, which reports the allocated public address. - mod
reqfamilyTheREQUESTED-ADDRESS-FAMILYattribute, for asking for an IPv4 or IPv6 allocation. - mod
reqtransTheREQUESTED-TRANSPORTattribute, which selects the relay's transport to peers. - mod
rsrvtokenTheRESERVATION-TOKENattribute, used to claim a previously reserved port. - struct
ProtocolProtocolis IANA assigned protocol number. - fn
allocate_requestShorthand for allocation request message type. - fn
create_permission_requestShorthand for create permission request type. - fn
refresh_requestShorthand for refresh request message type. - fn
send_indicationShorthand for send indication message type. - const
DEFAULT_PORTDEFAULT_PORTfor TURN is same as STUN. - const
DEFAULT_TLS_PORTDEFAULT_TLSPORTis for TURN over TLS and is same as STUN. - const
PROTO_TCPPROTO_TCPis IANA assigned protocol number for TCP. - const
PROTO_UDPPROTO_UDPis IANA assigned protocol number for UDP.
rtci_turn::proto::addfamily
The ADDITIONAL-ADDRESS-FAMILY attribute, for asking for an IPv6 relayed address beside the IPv4 one.
- struct
AdditionalAddressFamilyAdditionalAddressFamilyrepresents theADDITIONAL-ADDRESS-FAMILYattribute as defined in RFC 8656 Section 18.11. - const
ATTR_ADDITIONAL_ADDRESS_FAMILYTheADDITIONAL-ADDRESS-FAMILYattribute type (0x8000), comprehension-optional.
rtci_turn::proto::addr
Address helpers and the five-tuple that identifies an allocation.
rtci_turn::proto::addrerror
The ADDRESS-ERROR-CODE attribute, which says why one of two address families was not allocated.
- struct
AddressErrorCodeAddressErrorCoderepresents theADDRESS-ERROR-CODEattribute as defined in RFC 8656 Section 18.12. - const
ATTR_ADDRESS_ERROR_CODETheADDRESS-ERROR-CODEattribute type (0x8001), comprehension-optional.
rtci_turn::proto::chandata
ChannelData messages — the compact 4-byte framing for relayed data.
- struct
ChannelDataChannelDatarepresents theChannelDataMessage defined in RFC 8656 Section 12.4.
rtci_turn::proto::channum
The CHANNEL-NUMBER attribute.
- struct
ChannelNumberChannelNumberrepresentsCHANNEL-NUMBERattribute. Encoded asu16. - const
MAX_CHANNEL_NUMBERThe highest channel number a client may bind. - const
MIN_CHANNEL_NUMBERThe lowest channel number a client may bind.
rtci_turn::proto::connid
The CONNECTION-ID attribute of TCP allocations (RFC 6062), which names a peer's TCP connection.
- struct
ConnectionIdConnectionIdrepresents theCONNECTION-IDattribute as defined in RFC 6062 Section 6.2.1.
rtci_turn::proto::data
The DATA attribute, which carries relayed payloads in Send/Data indications.
- struct
DataDatarepresentsDATAattribute.
rtci_turn::proto::dontfrag
The DONT-FRAGMENT attribute, asking the server to set DF on relayed packets.
- struct
DontFragmentAttrDontFragmentAttrrepresentsDONT-FRAGMENTattribute.
rtci_turn::proto::evenport
The EVEN-PORT attribute, requesting an even relayed port (for RTP/RTCP pairs).
- struct
EvenPortEvenPortrepresentsEVEN-PORTattribute.
rtci_turn::proto::icmp
The ICMP attribute, which reports an ICMP error a relayed datagram met.
rtci_turn::proto::lifetime
The LIFETIME attribute, which sets and reports allocation expiry.
- struct
LifetimeLifetimerepresentsLIFETIMEattribute. - const
DEFAULT_LIFETIMEDEFAULT_LIFETIMEin RFC 8656 is 10 minutes.
rtci_turn::proto::peeraddr
The XOR-PEER-ADDRESS attribute, naming the peer in permission and data messages.
- struct
PeerAddressPeerAddressimplementsXOR-PEER-ADDRESSattribute. - type
XorPeerAddressPeerAddressimplementsXOR-PEER-ADDRESSattribute.
rtci_turn::proto::relayaddr
The XOR-RELAYED-ADDRESS attribute, which reports the allocated public address.
- struct
RelayedAddressRelayedAddressimplementsXOR-RELAYED-ADDRESSattribute. - type
XorRelayedAddressXorRelayedAddressimplementsXOR-RELAYED-ADDRESSattribute.
rtci_turn::proto::reqfamily
The REQUESTED-ADDRESS-FAMILY attribute, for asking for an IPv4 or IPv6 allocation.
- struct
RequestedAddressFamilyRequestedAddressFamilyrepresents theREQUESTED-ADDRESS-FAMILYAttribute as defined in RFC 8656 Section 18.6. - const
REQUESTED_FAMILY_IPV4Requests an IPv4 relayed address. - const
REQUESTED_FAMILY_IPV6Requests an IPv6 relayed address.
rtci_turn::proto::reqtrans
The REQUESTED-TRANSPORT attribute, which selects the relay's transport to peers.
- struct
RequestedTransportRequestedTransportrepresentsREQUESTED-TRANSPORTattribute.
rtci_turn::proto::rsrvtoken
The RESERVATION-TOKEN attribute, used to claim a previously reserved port.
- struct
ReservationTokenReservationTokenrepresentsRESERVATION-TOKENattribute.
rtci_turn::rest
Time-limited TURN credentials of the "TURN REST API" (draft-uberti-behave-turn-rest-00, section 2.2; coturn's use-auth-secret / static-auth-secret): the username is the credential's expiry as a Unix timestamp, optionally followed by a separator and an application-chosen id (1735689600:alice), and the password is base64(HMAC(secret, username)). A server that checks the timestamp on every …
- fn
rest_username_expiryWhen the REST usernameusernameexpires: its leading Unix timestamp, before the firstseparator(coturn's--rest-api-separator,:by default) or the whole username when it has none.Nonewhen that part is not a decimal number of seconds.
Generated from the sources of rtci-turn 0.5.0 at its release tag. Items made by macros and methods are on docs.rs.