[−][src]Crate turnclient
Simple async TURN client.
Usage:
- Create
TurnClientBuilder
build_and_send_request
split
the resulting thing toStream
andSink
- Wait for
AllocationGranted
event from Stream - Create permission or channel with
AddPermission
message - Send datagrams to the peer with a
SendTo
message toTurnClient
'sSink
interface, receive datagrams from the peer by handlingRecvFrom
message fromTurnClient
'sStream
interface.
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
- Error handling is ad-hoc
Box<dyn std::error::Error>
, with just a text strings. - 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
TurnClient | The thing to be |
TurnClientBuilder | Options for connecting to TURN server |
Enums
ChannelUsage | Whether to just create permission of also allocate a channel for it. I don't see much reasons not to allocate a channel. |
MessageFromTurnServer | Callbacks from |
MessageToTurnServer | Requests and indications to be sent to TURN server |
Type Definitions
Error | Primitive error handling used in this library. File an issue if you don't like it. |