Crate stun_agent

Source
Expand description

STUN Agent library for Rust.

This crate provides a STUN I/O-free protocol implementation. An I/O-free protocol implementation, often referred to as a sans-IO implementation, is a network protocol implementation that contains no code for network I/O or asynchronous flow control. This means the protocol implementation is agnostic to the underlying networking stack and can be used in any environment that provides the necessary network I/O and asynchronous flow control.

These STUN agents are designed for use in a client-server architecture where the client sends a request and the server responds.

This sans-IO protocol implementation is defined entirely in terms of synchronous functions returning synchronous results, without blocking or waiting for any form of I/O. This makes it suitable for a wide range of environments, enhancing testing, flexibility, correctness, re-usability and simplicity.

This library currently provides support for writing STUN clients. Support for writing servers is not yet implemented. The main element of this library is:

  • StunClient: The STUN client that sends STUN requests and indications to a STUN server.

Structs§

RttConfig
When using unreliable transport, such as UDP, the re-transmission timeout is calculated using the following parameters. The RTO is an estimate of the round-trip time (RTT) and is computed as described in RFC6298, with two exceptions. First, the initial value for RTO SHOULD be greater than or equal to 500 ms. Second, the value of RTO SHOULD NOT be rounded up to the nearest second. Rather, a 1 ms accuracy SHOULD be maintained.
StunAttributes
Even though the STUN message is a collection of attributes, The StunAttribute is used to simplify the addition and removal of attributes. The RFC8489 does not set neither a limit nor a specific order for the attributes that can be added to a message, nevertheless, there are certain restrictions that must be followed for the integrity and fingerprint attributes. The StunAttribute eases the manipulation of attributes while ensuring that the above restrictions are met.
StunClient
A STUN client is an entity that sends STUN requests and receives STUN responses and STUN indications. A STUN client can also send indications.
StunClienteBuilder
Builder for the STUN client. It allows to configure the client with the required parameters for the STUN usage.
StunPacket
A chunk of bytes that represents a STUN packet that can be cloned.
StunPacketDecodedError
Describes the error that can occur during the STUN packet decoding.
StunPacketDecoder
A STUN packet decoder that can be used to decode a STUN packet. The StunPacketDecoder is helpful when reading bytes from a stream oriented connection, such as a TCP stream, or even when reading bytes from a datagram oriented connection, such as a UDP socket when the STUN packet is fragmented.

Enums§

CredentialMechanism
Describes the kind of credential mechanism that can be used by the STUN agent.
Integrity
Describes the kind of integrity protection that can be used.
StunAgentError
Describes the error that can occur during the STUN agent operation.
StunPacketDecodedValue
Describes the possible outcomes of the STUN packet decoding.
StunPacketErrorType
Describe the error type that can occur during the STUN packet decoding.
StunTransactionError
Errors that can be raised by the STUN client when a transaction fails.
StuntClientEvent
Stun client events
TransportReliability
Description of the transport reliability, for STUN protocol communication. It can be reliable or unreliable depending on whether this is a UDP or TCP connection.