turn
Classes
| Name | Description |
|---|---|
Client | TURN client that manages relay allocations, permissions, and data relay via RFC 5766. |
FiveTuple | TURN allocation identity tuple: client remote address, server local address, and transport protocol. |
IAllocation | Base class for TURN relay allocations shared by client and server flows. |
PermissionPolicy | Lightweight server-side TURN permission policy. |
Request | A STUN message annotated with the transport type and source/destination addresses needed for server-side routing and response generation. |
Server | TURN server RFC 5766 / RFC 6062 implementation. Listens on UDP and/or TCP, authenticates requests via ServerObserver, and manages ServerAllocation objects for each 5-tuple. |
ServerAllocation | Server-side TURN allocation that tracks permissions, lifetime, and relay state. Handles Refresh and CreatePermission requests common to both UDP and TCP allocations. Subclassed by UDPAllocation and TCPAllocation for transport-specific behaviour. |
TCPAllocation | Server-side TCP TURN allocation with connection pair management per RFC 6062. Maintains a control connection for STUN signalling and an acceptor socket for incoming peer TCP connections. Each peer connection is tracked as a TCPConnectionPair and bridged to the client after a successful ConnectionBind. |
TCPClient | TCP transport TURN client with relay connection management per RFC 6062. Uses a single TCP control connection for STUN signalling and opens additional TCP relay connections for each peer via the Connect / ConnectionBind flow. |
TCPConnectionPair | Paired TCP connections forming a single TURN relay pipe between a client and a peer. Lifetime managed by IntrusivePtr; the owning TCPAllocation holds the Ptr in its pair map. |
UDPAllocation | Server-side UDP TURN allocation that relays datagrams to permitted peers. Binds a dedicated UDP relay socket for peer communication and forwards incoming datagrams to the client as Data Indications. |
UDPClient | UDP transport TURN client for datagram-based relay allocations. Uses a single UDP socket for both STUN signalling and Send/Data Indications. All Client methods apply; data is relayed via sendData() using Send Indications. |
ClientObserver | Abstract observer interface for TURN client events. Callers subclass this to receive allocation lifecycle and data relay callbacks. |
ClientState | State machine states for the TURN client. |
Permission | A single TURN permission entry associating a peer IP with a 5-minute expiry timer. Per RFC 5766 section 8, permissions last exactly 300 seconds and must be refreshed via a new CreatePermission request before they expire. |
RelayConnectionBinding | Binding metadata stored as socket opaque data during a ConnectionBind handshake. Associates a relay socket with its TURN connection ID and peer address. |
ServerObserver | Observer interface that the application must implement to participate in server-side allocation management and authentication. |
ServerOptions | Configuration options for the TURN server. |
TCPClientObserver | Observer interface for TCP TURN client events (RFC 6062). Extends ClientObserver with callbacks specific to TCP relay connections. |
Enumerations
| Name | Description |
|---|---|
AuthenticationState | Result returned by ServerObserver::authenticateRequest() to control how the server proceeds with an incoming STUN request. |
AuthenticationState
enum AuthenticationStateDefined in src/turn/include/icy/turn/types.h:50
Result returned by ServerObserver::authenticateRequest() to control how the server proceeds with an incoming STUN request.
| Value | Description |
|---|---|
Authenticating | Authentication is in progress; server holds the request. |
Authorized | Credentials verified; request may proceed. |
QuotaReached | User quota exceeded; respond with 486. |
NotAuthorized | Credentials rejected; respond with 401. |
Typedefs
| Return | Name | Description |
|---|---|---|
KVCollection< net::Address, net::SocketEmitter > | ConnectionManager | Relay connection registry keyed by peer address for RFC 6062 TCP relays. |
ConnectionManager::Map | ConnectionManagerMap | Underlying map type used by the TCP relay connection registry. |
std::vector< Permission > | PermissionList | Active TURN permissions associated with one allocation. |
std::map< FiveTuple, std::unique_ptr< ServerAllocation > > | ServerAllocationMap | Active server allocations keyed by the client/server 5-tuple. |
std::map< uint32_t, TCPConnectionPair::Ptr > | TCPConnectionPairMap | Accepted peer TCP connections keyed by TURN CONNECTION-ID. |
std::vector< std::string > | IPList | List of peer IP strings used when creating or refreshing permissions. |
ConnectionManager
using ConnectionManager = KVCollection< net::Address, net::SocketEmitter >Type: KVCollection< net::Address, net::SocketEmitter >
Defined in src/turn/include/icy/turn/client/tcpclient.h:78
Relay connection registry keyed by peer address for RFC 6062 TCP relays.
ConnectionManagerMap
using ConnectionManagerMap = ConnectionManager::MapType: ConnectionManager::Map
Defined in src/turn/include/icy/turn/client/tcpclient.h:81
Underlying map type used by the TCP relay connection registry.
PermissionList
using PermissionList = std::vector< Permission >Type: std::vector< Permission >
Defined in src/turn/include/icy/turn/permission.h:140
Active TURN permissions associated with one allocation.
ServerAllocationMap
using ServerAllocationMap = std::map< FiveTuple, std::unique_ptr< ServerAllocation > >Type: std::map< FiveTuple, std::unique_ptr< ServerAllocation > >
Defined in src/turn/include/icy/turn/server/server.h:120
Active server allocations keyed by the client/server 5-tuple.
TCPConnectionPairMap
using TCPConnectionPairMap = std::map< uint32_t, TCPConnectionPair::Ptr >Type: std::map< uint32_t, TCPConnectionPair::Ptr >
Defined in src/turn/include/icy/turn/server/tcpallocation.h:29
Accepted peer TCP connections keyed by TURN CONNECTION-ID.
IPList
using IPList = std::vector< std::string >Defined in src/turn/include/icy/turn/types.h:104
List of peer IP strings used when creating or refreshing permissions.
Variables
| Return | Name | Description |
|---|---|---|
constexpr std::int64_t | kClientTimerInterval static constexpr | Timer interval for client maintenance (30 seconds) |
constexpr std::int64_t | kClientDefaultLifetime static constexpr | Default client allocation lifetime (5 minutes, in milliseconds) |
constexpr long | kClientDefaultTimeout static constexpr | Default client transaction timeout (10 seconds) |
constexpr std::int64_t | kDefaultAllocationLifetime static constexpr | Default allocation lifetime: 10 minutes (in milliseconds) |
constexpr int | PERMISSION_LIFETIME static constexpr | Permission Lifetime MUST be 300 seconds (= 5 minutes). |
constexpr uint32_t | kServerDefaultLifetime static constexpr | Default server allocation lifetime (2 minutes, in milliseconds) |
constexpr uint32_t | kServerMaxLifetime static constexpr | Maximum server allocation lifetime (15 minutes, in milliseconds) |
constexpr int | kServerMaxPermissions static constexpr | Maximum number of permissions per allocation. |
constexpr int | kServerTimerInterval static constexpr | Server timer interval (10 seconds) |
constexpr int | kServerEarlyMediaBufferSize static constexpr | Early media buffer size. |
constexpr int | kConnectionBindTimeout static constexpr | ConnectionBind request timeout (30 seconds, in milliseconds) |
constexpr int | CLIENT_SOCK_BUF_SIZE static constexpr | Default socket buffer size for TURN client sockets. |
constexpr int | SERVER_SOCK_BUF_SIZE static constexpr | Default socket buffer size for TURN server sockets. |
constexpr uint8_t | kProtocolUDP static constexpr | TURN protocol numbers. |
constexpr uint8_t | kProtocolTCP static constexpr | IP protocol number for TCP. |
constexpr int | kErrorTryAlternate static constexpr | TURN/STUN error codes used in this module. |
constexpr int | kErrorBadRequest static constexpr | Request was malformed or missing required attributes. |
constexpr int | kErrorNotAuthorized static constexpr | Authentication failed or credentials were not accepted. |
constexpr int | kErrorForbidden static constexpr | Request was understood but is not permitted for this client. |
constexpr int | kErrorUnknownAttribute static constexpr | Request included an unsupported comprehension-required attribute. |
constexpr int | kErrorUnsupportedTransport static constexpr | Requested transport protocol is not supported by the server. |
constexpr int | kErrorAllocationMismatch static constexpr | Client attempted an allocation operation that conflicts with existing state. |
constexpr int | kErrorStaleNonce static constexpr | Authentication nonce expired and must be refreshed. |
constexpr int | kErrorWrongCredentials static constexpr | Supplied credentials were well formed but did not match the allocation. |
constexpr int | kErrorConnectionAlreadyExists static constexpr | TURN TCP connection binding already exists. |
constexpr int | kErrorConnectionTimeoutOrFailure static constexpr | TURN TCP peer connection attempt timed out or failed. |
constexpr int | kErrorAllocationQuotaReached static constexpr | User or server allocation quota was exceeded. |
constexpr int | kErrorInsufficientCapacity static constexpr | Server lacks capacity to satisfy the request. |
constexpr int | kErrorOperationNotSupported static constexpr | Request is recognized but not implemented by this server. |
kClientTimerInterval
static constexpr
constexpr std::int64_t kClientTimerInterval = 30 * 1000Defined in src/turn/include/icy/turn/client/client.h:114
Timer interval for client maintenance (30 seconds)
kClientDefaultLifetime
static constexpr
constexpr std::int64_t kClientDefaultLifetime = 5 * 60 * 1000Defined in src/turn/include/icy/turn/client/client.h:117
Default client allocation lifetime (5 minutes, in milliseconds)
kClientDefaultTimeout
static constexpr
constexpr long kClientDefaultTimeout = 10 * 1000Defined in src/turn/include/icy/turn/client/client.h:120
Default client transaction timeout (10 seconds)
kDefaultAllocationLifetime
static constexpr
constexpr std::int64_t kDefaultAllocationLifetime = 10 * 60 * 1000Defined in src/turn/include/icy/turn/iallocation.h:28
Default allocation lifetime: 10 minutes (in milliseconds)
PERMISSION_LIFETIME
static constexpr
constexpr int PERMISSION_LIFETIME = 5 * 60 * 1000Defined in src/turn/include/icy/turn/permission.h:31
Permission Lifetime MUST be 300 seconds (= 5 minutes).
kServerDefaultLifetime
static constexpr
constexpr uint32_t kServerDefaultLifetime = 2 * 60 * 1000Defined in src/turn/include/icy/turn/server/server.h:37
Default server allocation lifetime (2 minutes, in milliseconds)
kServerMaxLifetime
static constexpr
constexpr uint32_t kServerMaxLifetime = 15 * 60 * 1000Defined in src/turn/include/icy/turn/server/server.h:40
Maximum server allocation lifetime (15 minutes, in milliseconds)
kServerMaxPermissions
static constexpr
constexpr int kServerMaxPermissions = 10Defined in src/turn/include/icy/turn/server/server.h:43
Maximum number of permissions per allocation.
kServerTimerInterval
static constexpr
constexpr int kServerTimerInterval = 10 * 1000Defined in src/turn/include/icy/turn/server/server.h:46
Server timer interval (10 seconds)
kServerEarlyMediaBufferSize
static constexpr
constexpr int kServerEarlyMediaBufferSize = 8192Defined in src/turn/include/icy/turn/server/server.h:49
Early media buffer size.
kConnectionBindTimeout
static constexpr
constexpr int kConnectionBindTimeout = 30 * 1000Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:29
ConnectionBind request timeout (30 seconds, in milliseconds)
CLIENT_SOCK_BUF_SIZE
static constexpr
constexpr int CLIENT_SOCK_BUF_SIZE = 65536Defined in src/turn/include/icy/turn/types.h:24
Default socket buffer size for TURN client sockets.
SERVER_SOCK_BUF_SIZE
static constexpr
constexpr int SERVER_SOCK_BUF_SIZE = CLIENT_SOCK_BUF_SIZE * 32Defined in src/turn/include/icy/turn/types.h:25
Default socket buffer size for TURN server sockets.
kProtocolUDP
static constexpr
constexpr uint8_t kProtocolUDP = 17Defined in src/turn/include/icy/turn/types.h:28
TURN protocol numbers.
IP protocol number for UDP.
kProtocolTCP
static constexpr
constexpr uint8_t kProtocolTCP = 6Defined in src/turn/include/icy/turn/types.h:29
IP protocol number for TCP.
kErrorTryAlternate
static constexpr
constexpr int kErrorTryAlternate = 300Defined in src/turn/include/icy/turn/types.h:32
TURN/STUN error codes used in this module.
Client should retry against an alternate TURN server.
kErrorBadRequest
static constexpr
constexpr int kErrorBadRequest = 400Defined in src/turn/include/icy/turn/types.h:33
Request was malformed or missing required attributes.
kErrorNotAuthorized
static constexpr
constexpr int kErrorNotAuthorized = 401Defined in src/turn/include/icy/turn/types.h:34
Authentication failed or credentials were not accepted.
kErrorForbidden
static constexpr
constexpr int kErrorForbidden = 403Defined in src/turn/include/icy/turn/types.h:35
Request was understood but is not permitted for this client.
kErrorUnknownAttribute
static constexpr
constexpr int kErrorUnknownAttribute = 420Defined in src/turn/include/icy/turn/types.h:36
Request included an unsupported comprehension-required attribute.
kErrorUnsupportedTransport
static constexpr
constexpr int kErrorUnsupportedTransport = 442Defined in src/turn/include/icy/turn/types.h:37
Requested transport protocol is not supported by the server.
kErrorAllocationMismatch
static constexpr
constexpr int kErrorAllocationMismatch = 437Defined in src/turn/include/icy/turn/types.h:38
Client attempted an allocation operation that conflicts with existing state.
kErrorStaleNonce
static constexpr
constexpr int kErrorStaleNonce = 438Defined in src/turn/include/icy/turn/types.h:39
Authentication nonce expired and must be refreshed.
kErrorWrongCredentials
static constexpr
constexpr int kErrorWrongCredentials = 441Defined in src/turn/include/icy/turn/types.h:40
Supplied credentials were well formed but did not match the allocation.
kErrorConnectionAlreadyExists
static constexpr
constexpr int kErrorConnectionAlreadyExists = 446Defined in src/turn/include/icy/turn/types.h:41
TURN TCP connection binding already exists.
kErrorConnectionTimeoutOrFailure
static constexpr
constexpr int kErrorConnectionTimeoutOrFailure = 447Defined in src/turn/include/icy/turn/types.h:42
TURN TCP peer connection attempt timed out or failed.
kErrorAllocationQuotaReached
static constexpr
constexpr int kErrorAllocationQuotaReached = 486Defined in src/turn/include/icy/turn/types.h:43
User or server allocation quota was exceeded.
kErrorInsufficientCapacity
static constexpr
constexpr int kErrorInsufficientCapacity = 508Defined in src/turn/include/icy/turn/types.h:44
Server lacks capacity to satisfy the request.
kErrorOperationNotSupported
static constexpr
constexpr int kErrorOperationNotSupported = 600Defined in src/turn/include/icy/turn/types.h:45
Request is recognized but not implemented by this server.
