Expand description
Simple async TURN client.
Usage:
- Create
TurnClientBuilder build_and_send_requestsplitthe resulting thing toStreamandSink- Wait for
AllocationGrantedevent from Stream - Create permission or channel with
AddPermissionmessage - Send datagrams to the peer with a
SendTomessage toTurnClient’sSinkinterface, receive datagrams from the peer by handlingRecvFrommessage fromTurnClient’sStreaminterface.
You may want to build a stream -> map -> sink chain using Stream::forward or Sink::send_all.
You need to handle errors from Stream::poll, otherwise somebody can DoS your client by sending tricky packets.
Not implemented / TODO / cons:
- Removing permissions. They keep on getting refreshed until you close the entire allocation.
- Quadratical complexity, linear number of UDP datagrams in case of N actibe permissions.
- TCP or TLS transport.
- Using short-term credentials instead of long-term.
- “Don’t fragment” specifier on sent datagrams
- Even/odd port allocation
- Message-integrity is not checked for server replies.
- Allocation-heavy, uses
Vec<u8>for byte buffers.
Examples:
echo.rs- Connect to specified TURN server, authorize specified peer and act as an echo server for it.
Structs§
- Exported
Parameters - Exported parameters for resuming allocation
- Turn
Client - The thing to be
splittoStream<Item=MessageFromTurnServer>andSink<Item=MessageToTurnServer>. Look at crate-level doc for more details. - Turn
Client Builder - Options for connecting to TURN server
Enums§
- Channel
Usage - Whether to just create permission of also allocate a channel for it. I don’t see much reasons not to allocate a channel.
- Message
From Turn Server - Callbacks from
TurnServer - Message
ToTurn Server - Requests and indications to be sent to TURN server
Type Aliases§
- Error
anyhow-based error handling. File an issue if you want properthiserror-based errors.