turn

May 15, 2026 ยท View on GitHub

{#turnmodulerfc5766}

turn

The [TURN module (rfc5766)](#turnmodulerfc5766) module contains TURN (rfc5766) client and server implementations.

Namespaces

NameDescription
turnTURN allocation identity types and transport helpers.

{#turn}

turn

TURN allocation identity types and transport helpers.

Classes

NameDescription
ClientTURN client that manages relay allocations, permissions, and data relay via RFC 5766.
FiveTupleTURN allocation identity tuple: client remote address, server local address, and transport protocol.
IAllocationBase class for TURN relay allocations shared by client and server flows.
PermissionPolicyLightweight server-side TURN permission policy.
RequestA STUN message annotated with the transport type and source/destination addresses needed for server-side routing and response generation.
ServerTURN server RFC 5766 / RFC 6062 implementation. Listens on UDP and/or TCP, authenticates requests via ServerObserver, and manages ServerAllocation objects for each 5-tuple.
ServerAllocationServer-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.
TCPAllocationServer-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.
TCPClientTCP 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.
TCPConnectionPairPaired 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.
UDPAllocationServer-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.
UDPClientUDP 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.
ClientObserverAbstract observer interface for TURN client events. Callers subclass this to receive allocation lifecycle and data relay callbacks.
ClientStateState machine states for the TURN client.
PermissionA 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.
RelayConnectionBindingBinding metadata stored as socket opaque data during a ConnectionBind handshake. Associates a relay socket with its TURN connection ID and peer address.
ServerObserverObserver interface that the application must implement to participate in server-side allocation management and authentication.
ServerOptionsConfiguration options for the TURN server.
TCPClientObserverObserver interface for TCP TURN client events (RFC 6062). Extends ClientObserver with callbacks specific to TCP relay connections.

Enumerations

NameDescription
AuthenticationStateResult returned by ServerObserver::authenticateRequest() to control how the server proceeds with an incoming STUN request.

{#authenticationstate}

AuthenticationState

enum AuthenticationState

Result returned by ServerObserver::authenticateRequest() to control how the server proceeds with an incoming STUN request.

ValueDescription
AuthenticatingAuthentication is in progress; server holds the request.
AuthorizedCredentials verified; request may proceed.
QuotaReachedUser quota exceeded; respond with 486.
NotAuthorizedCredentials rejected; respond with 401.

Typedefs

ReturnNameDescription
KVCollection< net::Address, net::SocketEmitter >ConnectionManagerRelay connection registry keyed by peer address for RFC 6062 TCP relays.
ConnectionManager::MapConnectionManagerMapUnderlying map type used by the TCP relay connection registry.
std::vector< Permission >PermissionListActive TURN permissions associated with one allocation.
std::map< FiveTuple, std::unique_ptr< ServerAllocation > >ServerAllocationMapActive server allocations keyed by the client/server 5-tuple.
std::map< uint32_t, TCPConnectionPair::Ptr >TCPConnectionPairMapAccepted peer TCP connections keyed by TURN CONNECTION-ID.
std::vector< std::string >IPListList of peer IP strings used when creating or refreshing permissions.

{#connectionmanager}

ConnectionManager

using ConnectionManager = KVCollection< net::Address, net::SocketEmitter >

Relay connection registry keyed by peer address for RFC 6062 TCP relays.


{#connectionmanagermap}

ConnectionManagerMap

using ConnectionManagerMap = ConnectionManager::Map

Underlying map type used by the TCP relay connection registry.


{#permissionlist}

PermissionList

using PermissionList = std::vector< Permission >

Active TURN permissions associated with one allocation.


{#serverallocationmap}

ServerAllocationMap

using ServerAllocationMap = std::map< FiveTuple, std::unique_ptr< ServerAllocation > >

Active server allocations keyed by the client/server 5-tuple.


{#tcpconnectionpairmap}

TCPConnectionPairMap

using TCPConnectionPairMap = std::map< uint32_t, TCPConnectionPair::Ptr >

Accepted peer TCP connections keyed by TURN CONNECTION-ID.


{#iplist}

IPList

using IPList = std::vector< std::string >

List of peer IP strings used when creating or refreshing permissions.

Variables

ReturnNameDescription
std::int64_tkClientTimerInterval static constexprTimer interval for client maintenance (30 seconds).
std::int64_tkClientDefaultLifetime static constexprDefault client allocation lifetime (5 minutes, in milliseconds).
longkClientDefaultTimeout static constexprDefault client transaction timeout (10 seconds).
std::int64_tkDefaultAllocationLifetime static constexprDefault allocation lifetime: 10 minutes (in milliseconds).
intPERMISSION_LIFETIME static constexprPermission Lifetime MUST be 300 seconds (= 5 minutes).
uint32_tkServerDefaultLifetime static constexprDefault server allocation lifetime (2 minutes, in milliseconds).
uint32_tkServerMaxLifetime static constexprMaximum server allocation lifetime (15 minutes, in milliseconds).
intkServerMaxPermissions static constexprMaximum number of permissions per allocation.
intkServerTimerInterval static constexprServer timer interval (10 seconds).
intkServerEarlyMediaBufferSize static constexprEarly media buffer size.
intkConnectionBindTimeout static constexprConnectionBind request timeout (30 seconds, in milliseconds).
intCLIENT_SOCK_BUF_SIZE static constexprDefault socket buffer size for TURN client sockets.
intSERVER_SOCK_BUF_SIZE static constexprDefault socket buffer size for TURN server sockets.
uint8_tkProtocolUDP static constexprTURN protocol numbers.
uint8_tkProtocolTCP static constexprIP protocol number for TCP.
intkErrorTryAlternate static constexprTURN/STUN error codes used in this module.
intkErrorBadRequest static constexprRequest was malformed or missing required attributes.
intkErrorNotAuthorized static constexprAuthentication failed or credentials were not accepted.
intkErrorForbidden static constexprRequest was understood but is not permitted for this client.
intkErrorUnknownAttribute static constexprRequest included an unsupported comprehension-required attribute.
intkErrorUnsupportedTransport static constexprRequested transport protocol is not supported by the server.
intkErrorAllocationMismatch static constexprClient attempted an allocation operation that conflicts with existing state.
intkErrorStaleNonce static constexprAuthentication nonce expired and must be refreshed.
intkErrorWrongCredentials static constexprSupplied credentials were well formed but did not match the allocation.
intkErrorConnectionAlreadyExists static constexprTURN TCP connection binding already exists.
intkErrorConnectionTimeoutOrFailure static constexprTURN TCP peer connection attempt timed out or failed.
intkErrorAllocationQuotaReached static constexprUser or server allocation quota was exceeded.
intkErrorInsufficientCapacity static constexprServer lacks capacity to satisfy the request.
intkErrorOperationNotSupported static constexprRequest is recognized but not implemented by this server.

{#kclienttimerinterval}

kClientTimerInterval

static constexpr

std::int64_t kClientTimerInterval = 30 * 1000

Timer interval for client maintenance (30 seconds).


{#kclientdefaultlifetime}

kClientDefaultLifetime

static constexpr

std::int64_t kClientDefaultLifetime = 5 * 60 * 1000

Default client allocation lifetime (5 minutes, in milliseconds).


{#kclientdefaulttimeout}

kClientDefaultTimeout

static constexpr

long kClientDefaultTimeout = 10 * 1000

Default client transaction timeout (10 seconds).


{#kdefaultallocationlifetime}

kDefaultAllocationLifetime

static constexpr

std::int64_t kDefaultAllocationLifetime = 10 * 60 * 1000

Default allocation lifetime: 10 minutes (in milliseconds).


{#permission_lifetime}

PERMISSION_LIFETIME

static constexpr

int PERMISSION_LIFETIME = 5 * 60 * 1000

Permission Lifetime MUST be 300 seconds (= 5 minutes).


{#kserverdefaultlifetime}

kServerDefaultLifetime

static constexpr

uint32_t kServerDefaultLifetime = 2 * 60 * 1000

Default server allocation lifetime (2 minutes, in milliseconds).


{#kservermaxlifetime}

kServerMaxLifetime

static constexpr

uint32_t kServerMaxLifetime = 15 * 60 * 1000

Maximum server allocation lifetime (15 minutes, in milliseconds).


{#kservermaxpermissions}

kServerMaxPermissions

static constexpr

int kServerMaxPermissions = 10

Maximum number of permissions per allocation.


{#kservertimerinterval}

kServerTimerInterval

static constexpr

int kServerTimerInterval = 10 * 1000

Server timer interval (10 seconds).


{#kserverearlymediabuffersize}

kServerEarlyMediaBufferSize

static constexpr

int kServerEarlyMediaBufferSize = 8192

Early media buffer size.


{#kconnectionbindtimeout}

kConnectionBindTimeout

static constexpr

int kConnectionBindTimeout = 30 * 1000

ConnectionBind request timeout (30 seconds, in milliseconds).


{#client_sock_buf_size}

CLIENT_SOCK_BUF_SIZE

static constexpr

int CLIENT_SOCK_BUF_SIZE = 65536

Default socket buffer size for TURN client sockets.


{#server_sock_buf_size}

SERVER_SOCK_BUF_SIZE

static constexpr

int SERVER_SOCK_BUF_SIZE = CLIENT_SOCK_BUF_SIZE * 32

Default socket buffer size for TURN server sockets.


{#kprotocoludp}

kProtocolUDP

static constexpr

uint8_t kProtocolUDP = 17

TURN protocol numbers.

IP protocol number for UDP.


{#kprotocoltcp}

kProtocolTCP

static constexpr

uint8_t kProtocolTCP = 6

IP protocol number for TCP.


{#kerrortryalternate}

kErrorTryAlternate

static constexpr

int kErrorTryAlternate = 300

TURN/STUN error codes used in this module.

Client should retry against an alternate TURN server.


{#kerrorbadrequest}

kErrorBadRequest

static constexpr

int kErrorBadRequest = 400

Request was malformed or missing required attributes.


{#kerrornotauthorized}

kErrorNotAuthorized

static constexpr

int kErrorNotAuthorized = 401

Authentication failed or credentials were not accepted.


{#kerrorforbidden}

kErrorForbidden

static constexpr

int kErrorForbidden = 403

Request was understood but is not permitted for this client.


{#kerrorunknownattribute}

kErrorUnknownAttribute

static constexpr

int kErrorUnknownAttribute = 420

Request included an unsupported comprehension-required attribute.


{#kerrorunsupportedtransport}

kErrorUnsupportedTransport

static constexpr

int kErrorUnsupportedTransport = 442

Requested transport protocol is not supported by the server.


{#kerrorallocationmismatch}

kErrorAllocationMismatch

static constexpr

int kErrorAllocationMismatch = 437

Client attempted an allocation operation that conflicts with existing state.


{#kerrorstalenonce}

kErrorStaleNonce

static constexpr

int kErrorStaleNonce = 438

Authentication nonce expired and must be refreshed.


{#kerrorwrongcredentials}

kErrorWrongCredentials

static constexpr

int kErrorWrongCredentials = 441

Supplied credentials were well formed but did not match the allocation.


{#kerrorconnectionalreadyexists}

kErrorConnectionAlreadyExists

static constexpr

int kErrorConnectionAlreadyExists = 446

TURN TCP connection binding already exists.


{#kerrorconnectiontimeoutorfailure}

kErrorConnectionTimeoutOrFailure

static constexpr

int kErrorConnectionTimeoutOrFailure = 447

TURN TCP peer connection attempt timed out or failed.


{#kerrorallocationquotareached}

kErrorAllocationQuotaReached

static constexpr

int kErrorAllocationQuotaReached = 486

User or server allocation quota was exceeded.


{#kerrorinsufficientcapacity}

kErrorInsufficientCapacity

static constexpr

int kErrorInsufficientCapacity = 508

Server lacks capacity to satisfy the request.


{#kerroroperationnotsupported}

kErrorOperationNotSupported

static constexpr

int kErrorOperationNotSupported = 600

Request is recognized but not implemented by this server.

{#client-2}

Client

#include <icy/turn/client/client.h>
class Client

Defined in src/turn/include/icy/turn/client/client.h:124

Inherits: Stateful< ClientState >, IAllocation Subclassed by: TCPClient, UDPClient

TURN client that manages relay allocations, permissions, and data relay via RFC 5766.

List of all members

NameKindOwner
ClientfunctionDeclared here
startfunctionDeclared here
stopfunctionDeclared here
sendAllocatefunctionDeclared here
addPermissionfunctionDeclared here
addPermissionfunctionDeclared here
sendCreatePermissionfunctionDeclared here
sendChannelBindfunctionDeclared here
sendRefreshfunctionDeclared here
sendDatafunctionDeclared here
handleResponsefunctionDeclared here
handleAllocateResponsefunctionDeclared here
handleAllocateErrorResponsefunctionDeclared here
handleCreatePermissionResponsefunctionDeclared here
handleCreatePermissionErrorResponsefunctionDeclared here
handleRefreshResponsefunctionDeclared here
handleDataIndicationfunctionDeclared here
transportProtocolfunctionDeclared here
createTransactionfunctionDeclared here
authenticateRequestfunctionDeclared here
sendAuthenticatedTransactionfunctionDeclared here
removeTransactionfunctionDeclared here
mappedAddressfunctionDeclared here
relayedAddressfunctionDeclared here
closedfunctionDeclared here
observerfunctionDeclared here
optionsfunctionDeclared here
addPermissionfunctionDeclared here
hasPermissionfunctionDeclared here
hasPermissionfunctionDeclared here
removePermissionfunctionDeclared here
removePermissionfunctionDeclared here
_observervariableDeclared here
_optionsvariableDeclared here
_socketvariableDeclared here
_timervariableDeclared here
_errorvariableDeclared here
_mappedAddressvariableDeclared here
_relayedAddressvariableDeclared here
_realmvariableDeclared here
_noncevariableDeclared here
_pendingIndicationsvariableDeclared here
_transactionsvariableDeclared here
setErrorfunctionDeclared here
onSocketConnectfunctionDeclared here
onSocketRecvfunctionDeclared here
onSocketClosefunctionDeclared here
onTransactionProgressfunctionDeclared here
onStateChangefunctionDeclared here
onTimerfunctionDeclared here
StateChangevariableInherited from Stateful
_statevariableInherited from Stateful
StatefulfunctionInherited from Stateful
~StatefulfunctionInherited from Stateful
stateEqualsfunctionInherited from Stateful
stateBetweenfunctionInherited from Stateful
statefunctionInherited from Stateful
statefunctionInherited from Stateful
beforeStateChangefunctionInherited from Stateful
onStateChangefunctionInherited from Stateful
setStatefunctionInherited from Stateful
setStatefunctionInherited from Stateful
operator<<friendInherited from IAllocation
IAllocationfunctionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
updateUsagefunctionInherited from IAllocation
setLifetimefunctionInherited from IAllocation
setBandwidthLimitfunctionInherited from IAllocation
expiredfunctionInherited from IAllocation
deletedfunctionInherited from IAllocation
bandwidthLimitfunctionInherited from IAllocation
bandwidthUsedfunctionInherited from IAllocation
bandwidthRemainingfunctionInherited from IAllocation
timeRemainingfunctionInherited from IAllocation
tuplefunctionInherited from IAllocation
usernamefunctionInherited from IAllocation
lifetimefunctionInherited from IAllocation
permissionsfunctionInherited from IAllocation
relayedAddressfunctionInherited from IAllocation
addPermissionfunctionInherited from IAllocation
addPermissionfunctionInherited from IAllocation
addPermissionsfunctionInherited from IAllocation
removePermissionfunctionInherited from IAllocation
removePermissionfunctionInherited from IAllocation
removeAllPermissionsfunctionInherited from IAllocation
removeExpiredPermissionsfunctionInherited from IAllocation
hasPermissionfunctionInherited from IAllocation
hasPermissionfunctionInherited from IAllocation
printfunctionInherited from IAllocation
_tuplevariableInherited from IAllocation
_usernamevariableInherited from IAllocation
_permissionsvariableInherited from IAllocation
_lifetimevariableInherited from IAllocation
_bandwidthLimitvariableInherited from IAllocation
_bandwidthUsedvariableInherited from IAllocation
_createdAtvariableInherited from IAllocation
_updatedAtvariableInherited from IAllocation
_deletedvariableInherited from IAllocation

Inherited from Stateful

KindNameDescription
variableStateChangeSignals when the state changes.
variable_state
functionStateful inline
function~Stateful virtual inline
functionstateEquals virtual const inlineReturns true if the current state ID equals the given ID.
functionstateBetween virtual const inlineReturns true if the current state ID is in the inclusive range [lid, rid].
functionstate virtual inlineReturns a mutable reference to the current state.
functionstate virtual const inlineReturns a copy of the current state.
functionbeforeStateChange virtual inlineOverride to handle pre state change logic. Return false to prevent state change.
functiononStateChange virtual inlineOverride to handle post state change logic.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.

Inherited from IAllocation

KindNameDescription
friendoperator<< inline
functionIAllocation
functionIAllocationDeleted constructor.
functionIAllocationDeleted constructor.
functionupdateUsage virtualUpdates the last-activity timestamp and accumulates bandwidth usage. Call this whenever data is relayed through the allocation.
functionsetLifetime virtualSets the allocation lifetime in seconds and resets the activity timestamp, effectively extending the expiry from the current moment.
functionsetBandwidthLimit virtualSets the maximum number of bytes this allocation may relay in its lifetime. Pass 0 to disable bandwidth limiting.
functionexpired virtual const nodiscard
functiondeleted virtual const nodiscardReturns true if the allocation's deleted flag is set and or if the allocation has expired.
functionbandwidthLimit virtual const nodiscard
functionbandwidthUsed virtual const nodiscard
functionbandwidthRemaining virtual const nodiscard
functiontimeRemaining virtual const nodiscard
functiontuple virtual
functionusername virtual const nodiscard
functionlifetime virtual const nodiscard
functionpermissions virtual const nodiscard
functionrelayedAddress virtual const nodiscard
functionaddPermission virtualAdds a permission for ip, or refreshes the existing one.
functionaddPermission virtualAdds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only.
functionaddPermissions virtualAdds (or refreshes) permissions for multiple IPs.
functionremovePermission virtualRemoves the permission for ip if present.
functionremovePermission virtualRemoves the permission for address if present. The port is ignored; TURN permissions are IP-only.
functionremoveAllPermissions virtualRemoves all permissions from the list.
functionremoveExpiredPermissions virtualRemoves any permissions whose 5-minute lifetime has elapsed.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
functionprint virtual const inline
variable_tuple
variable_username
variable_permissions
variable_lifetime
variable_bandwidthLimit
variable_bandwidthUsed
variable_createdAt
variable_updatedAt
variable_deleted

Public Methods

ReturnNameDescription
Client
voidstart virtualConnects the socket to the TURN server and starts the allocation sequence. Permissions must be added via addPermission() before calling this.
voidstop virtualStops the timer, cancels pending transactions, and closes the socket.
voidsendAllocate virtualSends an Allocate request to the server with the configured transport and lifetime. On first call the server will typically respond with a 401 challenge; the client re-sends with credentials automatically.
voidaddPermission virtualAdds multiple peer IP addresses to the permission list.
voidaddPermission virtual overrideAdds a single peer IP to the permission list, or refreshes it if already present. Permissions should be added before start(); they may also be added later, in which case a new CreatePermission request is required.
voidsendCreatePermission virtualSends a CreatePermission request for all IPs currently in the permission list. Called automatically after allocation succeeds and periodically by the timer to refresh expiring permissions.
voidsendChannelBind virtualChannel bindings (RFC 5766 Section 11) are intentionally not implemented. They are a bandwidth optimization that replaces STUN-framed Send/Data indications with a compact 4-byte ChannelData header. This only benefits high-throughput media relay scenarios; in practice, media flows directly via ICE/DTLS rather than through this TURN client's data path, so the optimization is not worth the complexity (channel number allocation, 10-minute binding refresh timers, ChannelData wire framing). Data relay uses sendData() with Send Indications instead.
voidsendRefresh virtualSends a Refresh request to extend the allocation lifetime. Called automatically by the timer when roughly one-third of the lifetime remains.
voidsendData virtualSends a Send Indication to relay data to peerAddress through the TURN server. If permissions are still being negotiated the indication is queued and flushed once CreatePermission succeeds.
boolhandleResponse virtualDispatches an incoming STUN/TURN response to the appropriate handler.
voidhandleAllocateResponse virtualProcesses a successful Allocate response; extracts mapped/relayed addresses and advances the state to Authorizing, then sends CreatePermission.
voidhandleAllocateErrorResponse virtualHandles an Allocate error response; manages the 401 challenge/re-send flow and sets the client to Failed for unrecoverable errors.
voidhandleCreatePermissionResponse virtualHandles a successful CreatePermission response; flushes queued Send Indications and advances state to Success.
voidhandleCreatePermissionErrorResponse virtualHandles a failed CreatePermission response; clears all permissions and sets the client to Failed.
voidhandleRefreshResponse virtualHandles a Refresh response; updates the stored lifetime.
voidhandleDataIndication virtualHandles an incoming Data Indication; extracts peer address and data and forwards to ClientObserver::onRelayDataReceived().
inttransportProtocol virtual
stun::Transaction::PtrcreateTransaction virtualCreates a new STUN transaction, registers the progress callback, and adds it to the active transaction list.
voidauthenticateRequest virtualAdds STUN long-term credential attributes (Username, Realm, Nonce, MessageIntegrity) to request if the realm has been received from the server.
boolsendAuthenticatedTransaction virtualCalls authenticateRequest() then sends the transaction.
stun::Transaction::PtrremoveTransaction virtualRemoves a transaction from the active list. The IntrusivePtr keeps the object alive until the caller's copy is released.
net::AddressmappedAddress const nodiscard
net::AddressrelayedAddress virtual const nodiscard override
boolclosed const nodiscard
ClientObserver &observer
const Options &options const nodiscard
voidaddPermission virtualAdds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only.
boolhasPermission virtual nodiscardChecks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted.
boolhasPermission virtual nodiscardChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
voidremovePermission virtualRemoves the permission for ip if present.
voidremovePermission virtualRemoves the permission for address if present. The port is ignored; TURN permissions are IP-only.

{#client-3}

Client

Client(ClientObserver & observer, const Options & options, const net::Socket::Ptr & socket)

Defined in src/turn/include/icy/turn/client/client.h:161

Parameters

  • observer Observer to receive lifecycle and data callbacks.

  • options Configuration for this client instance.

  • socket Underlying transport socket (TCP or UDP).


{#start-13}

start

virtual

virtual void start()

Defined in src/turn/include/icy/turn/client/client.h:166

Connects the socket to the TURN server and starts the allocation sequence. Permissions must be added via addPermission() before calling this.

Reimplemented by

{#stop-10}

stop

virtual

virtual void stop()

Defined in src/turn/include/icy/turn/client/client.h:169

Stops the timer, cancels pending transactions, and closes the socket.

Reimplemented by

{#sendallocate}

sendAllocate

virtual

virtual void sendAllocate()

Defined in src/turn/include/icy/turn/client/client.h:175

Sends an Allocate request to the server with the configured transport and lifetime. On first call the server will typically respond with a 401 challenge; the client re-sends with credentials automatically.


{#addpermission}

addPermission

virtual

virtual void addPermission(const IPList & peerIPs)

Defined in src/turn/include/icy/turn/client/client.h:179

Adds multiple peer IP addresses to the permission list.

Parameters

  • peerIPs List of IPv4 address strings to permit.

{#addpermission-1}

addPermission

virtual override

virtual void addPermission(const std::string & ip) override

Defined in src/turn/include/icy/turn/client/client.h:186

Adds a single peer IP to the permission list, or refreshes it if already present. Permissions should be added before start(); they may also be added later, in which case a new CreatePermission request is required.

Parameters

  • ip IPv4 address string of the permitted peer.
Reimplements

{#sendcreatepermission}

sendCreatePermission

virtual

virtual void sendCreatePermission()

Defined in src/turn/include/icy/turn/client/client.h:191

Sends a CreatePermission request for all IPs currently in the permission list. Called automatically after allocation succeeds and periodically by the timer to refresh expiring permissions.


{#sendchannelbind}

sendChannelBind

virtual

virtual void sendChannelBind(const std::string & peerIP)

Defined in src/turn/include/icy/turn/client/client.h:202

Channel bindings (RFC 5766 Section 11) are intentionally not implemented. They are a bandwidth optimization that replaces STUN-framed Send/Data indications with a compact 4-byte ChannelData header. This only benefits high-throughput media relay scenarios; in practice, media flows directly via ICE/DTLS rather than through this TURN client's data path, so the optimization is not worth the complexity (channel number allocation, 10-minute binding refresh timers, ChannelData wire framing). Data relay uses sendData() with Send Indications instead.

Parameters

  • peerIP Unused; always throws std::logic_error.

{#sendrefresh}

sendRefresh

virtual

virtual void sendRefresh()

Defined in src/turn/include/icy/turn/client/client.h:207

Sends a Refresh request to extend the allocation lifetime. Called automatically by the timer when roughly one-third of the lifetime remains.


{#senddata}

sendData

virtual

virtual void sendData(const char * data, size_t size, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/client/client.h:215

Sends a Send Indication to relay data to peerAddress through the TURN server. If permissions are still being negotiated the indication is queued and flushed once CreatePermission succeeds.

Parameters

  • data Pointer to the payload to relay.

  • size Number of bytes to relay.

  • peerAddress Destination peer address (must have an active permission).

Reimplemented by

{#handleresponse}

handleResponse

virtual

virtual bool handleResponse(const stun::Message & response)

Defined in src/turn/include/icy/turn/client/client.h:220

Dispatches an incoming STUN/TURN response to the appropriate handler.

Parameters

  • response Received STUN message.

Returns

true if the message was handled, false if it was unrecognised.

Reimplemented by

{#handleallocateresponse}

handleAllocateResponse

virtual

virtual void handleAllocateResponse(const stun::Message & response)

Defined in src/turn/include/icy/turn/client/client.h:225

Processes a successful Allocate response; extracts mapped/relayed addresses and advances the state to Authorizing, then sends CreatePermission.

Parameters

  • response Allocate success response from the server.

{#handleallocateerrorresponse}

handleAllocateErrorResponse

virtual

virtual void handleAllocateErrorResponse(const stun::Message & response)

Defined in src/turn/include/icy/turn/client/client.h:230

Handles an Allocate error response; manages the 401 challenge/re-send flow and sets the client to Failed for unrecoverable errors.

Parameters

  • response Allocate error response from the server.

{#handlecreatepermissionresponse}

handleCreatePermissionResponse

virtual

virtual void handleCreatePermissionResponse(const stun::Message & response)

Defined in src/turn/include/icy/turn/client/client.h:235

Handles a successful CreatePermission response; flushes queued Send Indications and advances state to Success.

Parameters

  • response CreatePermission success response from the server.

{#handlecreatepermissionerrorresponse}

handleCreatePermissionErrorResponse

virtual

virtual void handleCreatePermissionErrorResponse(const stun::Message & response)

Defined in src/turn/include/icy/turn/client/client.h:240

Handles a failed CreatePermission response; clears all permissions and sets the client to Failed.

Parameters

  • response CreatePermission error response from the server.

{#handlerefreshresponse}

handleRefreshResponse

virtual

virtual void handleRefreshResponse(const stun::Message & response)

Defined in src/turn/include/icy/turn/client/client.h:244

Handles a Refresh response; updates the stored lifetime.

Parameters

  • response Refresh response from the server.

{#handledataindication}

handleDataIndication

virtual

virtual void handleDataIndication(const stun::Message & response)

Defined in src/turn/include/icy/turn/client/client.h:249

Handles an incoming Data Indication; extracts peer address and data and forwards to ClientObserver::onRelayDataReceived().

Parameters

  • response Data Indication message from the server.

{#transportprotocol}

transportProtocol

virtual

virtual int transportProtocol()

Defined in src/turn/include/icy/turn/client/client.h:253

Returns

The IANA protocol number for the underlying transport (kProtocolUDP or kProtocolTCP).

Reimplemented by

{#createtransaction}

createTransaction

virtual

virtual stun::Transaction::Ptr createTransaction(const net::Socket::Ptr & socket = nullptr)

Defined in src/turn/include/icy/turn/client/client.h:259

Creates a new STUN transaction, registers the progress callback, and adds it to the active transaction list.

Parameters

  • socket Optional override socket; uses the control socket if nullptr.

Returns

IntrusivePtr to the new transaction.


{#authenticaterequest}

authenticateRequest

virtual

virtual void authenticateRequest(stun::Message & request)

Defined in src/turn/include/icy/turn/client/client.h:264

Adds STUN long-term credential attributes (Username, Realm, Nonce, MessageIntegrity) to request if the realm has been received from the server.

Parameters

  • request Message to decorate with authentication attributes.

{#sendauthenticatedtransaction}

sendAuthenticatedTransaction

virtual

virtual bool sendAuthenticatedTransaction(stun::Transaction * transaction)

Defined in src/turn/include/icy/turn/client/client.h:269

Calls authenticateRequest() then sends the transaction.

Parameters

  • transaction Transaction whose request to authenticate and send.

Returns

true if the send succeeded.


{#removetransaction}

removeTransaction

virtual

virtual stun::Transaction::Ptr removeTransaction(stun::Transaction * transaction)

Defined in src/turn/include/icy/turn/client/client.h:275

Removes a transaction from the active list. The IntrusivePtr keeps the object alive until the caller's copy is released.

Parameters

  • transaction Transaction to remove.

Returns

The removed Ptr, or nullptr if not found.


{#mappedaddress}

mappedAddress

const nodiscard

[[nodiscard]] net::Address mappedAddress() const

Defined in src/turn/include/icy/turn/client/client.h:278

Returns

The server-reflexive (mapped) address assigned by the TURN server.


{#relayedaddress}

relayedAddress

virtual const nodiscard override

[[nodiscard]] virtual net::Address relayedAddress() const override

Defined in src/turn/include/icy/turn/client/client.h:281

Returns

The relayed transport address assigned by the TURN server.

Reimplements

{#closed-5}

closed

const nodiscard

[[nodiscard]] bool closed() const

Defined in src/turn/include/icy/turn/client/client.h:284

Returns

true when the client is in the None or Failed state.


{#observer-1}

observer

ClientObserver & observer()

Defined in src/turn/include/icy/turn/client/client.h:287

Returns

Reference to the observer provided at construction.


{#options-8}

options

const nodiscard

[[nodiscard]] const Options & options() const

Defined in src/turn/include/icy/turn/client/client.h:290

Returns

Reference to the immutable options struct.


{#addpermission-2}

addPermission

virtual

virtual void addPermission(const net::Address & address)

Defined in src/turn/include/icy/turn/client/client.h:154

Adds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only.

Reimplements

{#haspermission}

hasPermission

virtual nodiscard

[[nodiscard]] virtual bool hasPermission(const std::string & peerIP)

Defined in src/turn/include/icy/turn/client/client.h:155

Checks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted.

Parameters

  • peerIP IPv4 address string to check.

Returns

true if a valid (non-expired) permission exists.

Reimplements

{#haspermission-1}

hasPermission

virtual nodiscard

[[nodiscard]] virtual bool hasPermission(const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/client/client.h:155

Checks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.

Reimplements

{#removepermission}

removePermission

virtual

virtual void removePermission(const std::string & ip)

Defined in src/turn/include/icy/turn/client/client.h:156

Removes the permission for ip if present.

Parameters

  • ip IPv4 address string to remove.
Reimplements

{#removepermission-1}

removePermission

virtual

virtual void removePermission(const net::Address & address)

Defined in src/turn/include/icy/turn/client/client.h:156

Removes the permission for address if present. The port is ignored; TURN permissions are IP-only.

Reimplements

Protected Attributes

ReturnNameDescription
ClientObserver &_observer
Options_options
net::SocketEmitter_socket
Timer_timer
icy::Error_error
net::Address_mappedAddress
net::Address_relayedAddress
std::string_realm
std::string_nonce
std::deque< stun::Message >_pendingIndicationsA list of queued Send indication packets awaiting server permissions.
std::vector< stun::Transaction::Ptr >_transactionsA list containing currently active transactions.

{#_observer-1}

_observer

ClientObserver & _observer

Defined in src/turn/include/icy/turn/client/client.h:324


{#_options-3}

_options

Options _options

Defined in src/turn/include/icy/turn/client/client.h:325


{#_socket-3}

_socket

net::SocketEmitter _socket

Defined in src/turn/include/icy/turn/client/client.h:326


{#_timer-1}

_timer

Timer _timer

Defined in src/turn/include/icy/turn/client/client.h:327


{#_error-5}

_error

icy::Error _error

Defined in src/turn/include/icy/turn/client/client.h:328


{#_mappedaddress}

_mappedAddress

net::Address _mappedAddress

Defined in src/turn/include/icy/turn/client/client.h:329


{#_relayedaddress}

_relayedAddress

net::Address _relayedAddress

Defined in src/turn/include/icy/turn/client/client.h:330


{#_realm}

_realm

std::string _realm

Defined in src/turn/include/icy/turn/client/client.h:332


{#_nonce}

_nonce

std::string _nonce

Defined in src/turn/include/icy/turn/client/client.h:333


{#_pendingindications}

_pendingIndications

std::deque< stun::Message > _pendingIndications

Defined in src/turn/include/icy/turn/client/client.h:336

A list of queued Send indication packets awaiting server permissions.


{#_transactions}

_transactions

std::vector< stun::Transaction::Ptr > _transactions

Defined in src/turn/include/icy/turn/client/client.h:339

A list containing currently active transactions.

Protected Methods

ReturnNameDescription
voidsetError virtualSets the error field and transitions the client to the Failed state.
boolonSocketConnect virtualSocket connect callback; starts the timer and sends the first Allocate request.
boolonSocketRecv virtualSocket receive callback; parses STUN messages from the buffer and dispatches them.
boolonSocketClose virtualSocket close callback; shuts down the client and records the socket error.
voidonTransactionProgress virtualSTUN transaction state-change callback; handles Success and Failed outcomes.
voidonStateChange overrideForwards state-change events to the observer.
voidonTimer virtualPeriodic timer callback; re-allocates on expiry or refreshes when lifetime is below one-third remaining. Also calls ClientObserver::onTimer().

{#seterror-5}

setError

virtual

virtual void setError(const icy::Error & error)

Defined in src/turn/include/icy/turn/client/client.h:295

Sets the error field and transitions the client to the Failed state.

Parameters

  • error Error descriptor.

{#onsocketconnect-5}

onSocketConnect

virtual

virtual bool onSocketConnect(net::Socket & socket)

Defined in src/turn/include/icy/turn/client/client.h:299

Socket connect callback; starts the timer and sends the first Allocate request.

Parameters

  • socket The connected socket.

{#onsocketrecv-7}

onSocketRecv

virtual

virtual bool onSocketRecv(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/client/client.h:305

Socket receive callback; parses STUN messages from the buffer and dispatches them.

Parameters

  • socket The receiving socket.

  • buffer Received data.

  • peerAddress Source address of the received data.


{#onsocketclose-5}

onSocketClose

virtual

virtual bool onSocketClose(net::Socket & socket)

Defined in src/turn/include/icy/turn/client/client.h:309

Socket close callback; shuts down the client and records the socket error.

Parameters

  • socket The closed socket.

{#ontransactionprogress}

onTransactionProgress

virtual

virtual void onTransactionProgress(void * sender, TransactionState & state, const TransactionState &)

Defined in src/turn/include/icy/turn/client/client.h:314

STUN transaction state-change callback; handles Success and Failed outcomes.

Parameters

  • sender Pointer to the stun::Transaction that changed state.

  • state The new transaction state.


{#onstatechange-1}

onStateChange

override

void onStateChange(ClientState & state, const ClientState & oldState) override

Defined in src/turn/include/icy/turn/client/client.h:317

Forwards state-change events to the observer.


{#ontimer-1}

onTimer

virtual

virtual void onTimer()

Defined in src/turn/include/icy/turn/client/client.h:321

Periodic timer callback; re-allocates on expiry or refreshes when lifetime is below one-third remaining. Also calls ClientObserver::onTimer().

{#options-9}

Options

#include <icy/turn/client/client.h>
struct Options

Defined in src/turn/include/icy/turn/client/client.h:129

Configuration options for the TURN client.

List of all members

NameKindOwner
softwarevariableDeclared here
usernamevariableDeclared here
passwordvariableDeclared here
timeoutvariableDeclared here
lifetimevariableDeclared here
timerIntervalvariableDeclared here
serverAddrvariableDeclared here
OptionsfunctionDeclared here

Public Attributes

ReturnNameDescription
std::stringsoftware
std::stringusername
std::stringpassword
longtimeout
std::int64_tlifetime
std::int64_ttimerInterval
net::AddressserverAddr

{#software}

software

std::string software

Defined in src/turn/include/icy/turn/client/client.h:131


{#username-2}

username

std::string username

Defined in src/turn/include/icy/turn/client/client.h:132


{#password-2}

password

std::string password

Defined in src/turn/include/icy/turn/client/client.h:134


{#timeout-1}

timeout

long timeout

Defined in src/turn/include/icy/turn/client/client.h:136


{#lifetime}

lifetime

std::int64_t lifetime

Defined in src/turn/include/icy/turn/client/client.h:137


{#timerinterval}

timerInterval

std::int64_t timerInterval

Defined in src/turn/include/icy/turn/client/client.h:138


{#serveraddr}

serverAddr

net::Address serverAddr

Defined in src/turn/include/icy/turn/client/client.h:139

Public Methods

ReturnNameDescription
Options inline

{#options-10}

Options

inline

inline Options()

Defined in src/turn/include/icy/turn/client/client.h:140

{#fivetuple}

FiveTuple

#include <icy/turn/fivetuple.h>
class FiveTuple

Defined in src/turn/include/icy/turn/fivetuple.h:69

TURN allocation identity tuple: client remote address, server local address, and transport protocol.

The TURN 5-tuple consists of a local address, a remote address, and the transport protocol used by the client to communicate with the server.

                                                          +---------+
                                                          |         |
                                                          | External|
                                                        / | Client  |
                                                      //  |         |
                                                     /    |         |
                                                   //     +---------+
                                                  /
                                                //
                +-+                            /
                | |                           /
                | |                         //
 +---------+    | |          +---------+   /              +---------+
 |         |    |N|          |         | //               |         |
 | TURN    |    | |          |         |/                 | External|
 | Client  |----|A|----------|   TURN  |------------------| Client  |
 |         |    | |^        ^|  Server |^                ^|         |
 |         |    |T||        ||         ||                ||         |
 +---------+    | ||        |+---------+|                |+---------+
    ^           | ||        |           |                |
    |           | ||        |           |                |
    |           +-+|        |           |                |
    |              |        |           |                |
    |
               Internal     Internal    External         External
Client         Remote       Local       Local            Remote
Performing     Transport    Transport   Transport        Transport
Allocations    Address      Address     Address          Address

                   |          |            |                |
                   +-----+----+            +--------+-------+
                         |                          |
                         |                          |

                       Internal                External
                       5-Tuple                 5-tuple

List of all members

NameKindOwner
operator<<friendDeclared here
FiveTuplefunctionDeclared here
FiveTuplefunctionDeclared here
FiveTuplefunctionDeclared here
remotefunctionDeclared here
localfunctionDeclared here
transportfunctionDeclared here
remotefunctionDeclared here
localfunctionDeclared here
transportfunctionDeclared here
operator==functionDeclared here
operator<functionDeclared here
toStringfunctionDeclared here
_remotevariableDeclared here
_localvariableDeclared here
_transportvariableDeclared here

Friends

NameDescription
operator<< inline

{#operator-25}

operator<<

inline

friend inline std::ostream & operator<<(std::ostream & stream, const FiveTuple & tuple)

Defined in src/turn/include/icy/turn/fivetuple.h:118

Public Methods

ReturnNameDescription
FiveTupleConstructs a default FiveTuple with empty addresses and UDP transport.
FiveTupleConstructs a FiveTuple from explicit addresses and transport.
FiveTupleCopy constructor.
const net::Address &remote const inline nodiscard
const net::Address &local const inline nodiscard
const net::TransportType &transport const inline nodiscard
voidremote inlineSets the remote address.
voidlocal inlineSets the local address.
voidtransport inlineSets the transport protocol.
booloperator== constEquality comparison; all three components must match.
booloperator< constLess-than ordering based on remote then local port; used as std::map key.
std::stringtoString const nodiscard

{#fivetuple-1}

FiveTuple

FiveTuple()

Defined in src/turn/include/icy/turn/fivetuple.h:73

Constructs a default FiveTuple with empty addresses and UDP transport.


{#fivetuple-2}

FiveTuple

FiveTuple(const net::Address & remote, const net::Address & local, net::TransportType transport)

Defined in src/turn/include/icy/turn/fivetuple.h:79

Constructs a FiveTuple from explicit addresses and transport.

Parameters

  • remote Client's remote transport address (as seen by the server).

  • local Server's local transport address.

  • transport Protocol in use (net::UDP or net::TCP).


{#fivetuple-3}

FiveTuple

FiveTuple(const FiveTuple & r)

Defined in src/turn/include/icy/turn/fivetuple.h:83

Copy constructor.


{#remote-2}

remote

const inline nodiscard

[[nodiscard]] inline const net::Address & remote() const

Defined in src/turn/include/icy/turn/fivetuple.h:86

Returns

The remote (client-side) transport address.


{#local-2}

local

const inline nodiscard

[[nodiscard]] inline const net::Address & local() const

Defined in src/turn/include/icy/turn/fivetuple.h:89

Returns

The local (server-side) transport address.


{#transport-4}

transport

const inline nodiscard

[[nodiscard]] inline const net::TransportType & transport() const

Defined in src/turn/include/icy/turn/fivetuple.h:92

Returns

The transport protocol for this tuple.


{#remote-3}

remote

inline

inline void remote(const net::Address & remote)

Defined in src/turn/include/icy/turn/fivetuple.h:96

Sets the remote address.

Parameters

  • remote New remote address.

{#local-3}

local

inline

inline void local(const net::Address & local)

Defined in src/turn/include/icy/turn/fivetuple.h:100

Sets the local address.

Parameters

  • local New local address.

{#transport-5}

transport

inline

inline void transport(const net::TransportType & transport)

Defined in src/turn/include/icy/turn/fivetuple.h:104

Sets the transport protocol.

Parameters

  • transport New transport type.

{#operator-26}

operator==

const

bool operator==(const FiveTuple & r) const

Defined in src/turn/include/icy/turn/fivetuple.h:110

Equality comparison; all three components must match.


{#operator-27}

operator<

const

bool operator<(const FiveTuple & r) const

Defined in src/turn/include/icy/turn/fivetuple.h:113

Less-than ordering based on remote then local port; used as std::map key.


{#tostring-7}

toString

const nodiscard

[[nodiscard]] std::string toString() const

Defined in src/turn/include/icy/turn/fivetuple.h:116

Returns

A human-readable string of the form "FiveTuple[remote:local:transport]".

Private Attributes

ReturnNameDescription
net::Address_remote
net::Address_local
net::TransportType_transport

{#_remote-1}

_remote

net::Address _remote

Defined in src/turn/include/icy/turn/fivetuple.h:126


{#_local-1}

_local

net::Address _local

Defined in src/turn/include/icy/turn/fivetuple.h:127


{#_transport}

_transport

net::TransportType _transport

Defined in src/turn/include/icy/turn/fivetuple.h:128

{#iallocation}

IAllocation

#include <icy/turn/iallocation.h>
class IAllocation

Defined in src/turn/include/icy/turn/iallocation.h:75

Subclassed by: Client, ServerAllocation

Base class for TURN relay allocations shared by client and server flows.

All TURN operations revolve around allocations, and all TURN messages are associated with an allocation. An allocation conceptually consists of:

  • the relayed transport address;

  • the 5-tuple: client's IP address, client's port, server IP address, server port, and transport protocol;

  • the authentication information;

  • the time-to-expiry;

  • a list of permissions;

  • a list of channel-to-peer bindings.

The relayed transport address is the transport address allocated by the server for communicating with peers, while the 5-tuple describes the communication path between the client and the server. On the client, the 5-tuple uses the client's host transport address; on the server, the 5-tuple uses the client's server-reflexive transport address.

Both the relayed transport address and the 5-tuple must be unique across all allocations, so either one can be used to uniquely identify the allocation.

The authentication information, such as username, password, realm, and nonce, is used to verify subsequent requests and compute the message integrity of responses. The username, realm, and nonce values are initially those used in the authenticated Allocate request that creates the allocation, though the server can change the nonce during the allocation lifetime using a 438 (Stale Nonce) reply. Rather than storing the password explicitly, a server may prefer to store the key value, which is an MD5 hash over the username, realm, and password as described by RFC 5389.

The time-to-expiry is the time left until the allocation expires. Each Allocate or Refresh transaction resets this timer, which then ticks down toward zero. By default, each Allocate or Refresh resets the lifetime to 600 seconds (10 minutes), but the client can request a different value in the Allocate and Refresh requests. Allocations can only be refreshed using Refresh; sending data to a peer does not refresh an allocation. When an allocation expires, the state data associated with it can be freed.

List of all members

NameKindOwner
operator<<friendDeclared here
IAllocationfunctionDeclared here
IAllocationfunctionDeclared here
IAllocationfunctionDeclared here
updateUsagefunctionDeclared here
setLifetimefunctionDeclared here
setBandwidthLimitfunctionDeclared here
expiredfunctionDeclared here
deletedfunctionDeclared here
bandwidthLimitfunctionDeclared here
bandwidthUsedfunctionDeclared here
bandwidthRemainingfunctionDeclared here
timeRemainingfunctionDeclared here
tuplefunctionDeclared here
usernamefunctionDeclared here
lifetimefunctionDeclared here
permissionsfunctionDeclared here
relayedAddressfunctionDeclared here
addPermissionfunctionDeclared here
addPermissionfunctionDeclared here
addPermissionsfunctionDeclared here
removePermissionfunctionDeclared here
removePermissionfunctionDeclared here
removeAllPermissionsfunctionDeclared here
removeExpiredPermissionsfunctionDeclared here
hasPermissionfunctionDeclared here
hasPermissionfunctionDeclared here
printfunctionDeclared here
_tuplevariableDeclared here
_usernamevariableDeclared here
_permissionsvariableDeclared here
_lifetimevariableDeclared here
_bandwidthLimitvariableDeclared here
_bandwidthUsedvariableDeclared here
_createdAtvariableDeclared here
_updatedAtvariableDeclared here
_deletedvariableDeclared here

Friends

NameDescription
operator<< inline

{#operator-28}

operator<<

inline

friend inline std::ostream & operator<<(std::ostream & stream, const IAllocation & alloc)

Defined in src/turn/include/icy/turn/iallocation.h:187

Public Methods

ReturnNameDescription
IAllocation
IAllocationDeleted constructor.
IAllocationDeleted constructor.
voidupdateUsage virtualUpdates the last-activity timestamp and accumulates bandwidth usage. Call this whenever data is relayed through the allocation.
voidsetLifetime virtualSets the allocation lifetime in seconds and resets the activity timestamp, effectively extending the expiry from the current moment.
voidsetBandwidthLimit virtualSets the maximum number of bytes this allocation may relay in its lifetime. Pass 0 to disable bandwidth limiting.
boolexpired virtual const nodiscard
booldeleted virtual const nodiscardReturns true if the allocation's deleted flag is set and or if the allocation has expired.
std::int64_tbandwidthLimit virtual const nodiscard
std::int64_tbandwidthUsed virtual const nodiscard
std::int64_tbandwidthRemaining virtual const nodiscard
std::int64_ttimeRemaining virtual const nodiscard
FiveTuple &tuple virtual
std::stringusername virtual const nodiscard
std::int64_tlifetime virtual const nodiscard
PermissionListpermissions virtual const nodiscard
net::AddressrelayedAddress virtual const nodiscard
voidaddPermission virtualAdds a permission for ip, or refreshes the existing one.
voidaddPermission virtualAdds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only.
voidaddPermissions virtualAdds (or refreshes) permissions for multiple IPs.
voidremovePermission virtualRemoves the permission for ip if present.
voidremovePermission virtualRemoves the permission for address if present. The port is ignored; TURN permissions are IP-only.
voidremoveAllPermissions virtualRemoves all permissions from the list.
voidremoveExpiredPermissions virtualRemoves any permissions whose 5-minute lifetime has elapsed.
boolhasPermission virtual nodiscardChecks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted.
boolhasPermission virtual nodiscardChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
voidprint virtual const inline

{#iallocation-1}

IAllocation

IAllocation(const FiveTuple & tuple = FiveTuple(), const std::string & username = "", std::int64_t lifetime = kDefaultAllocationLifetime)

Defined in src/turn/include/icy/turn/iallocation.h:81

Parameters

  • tuple The 5-tuple identifying this allocation.

  • username Authenticated username associated with this allocation.

  • lifetime Initial lifetime in seconds.


{#iallocation-2}

IAllocation

IAllocation(const IAllocation &) = delete

Defined in src/turn/include/icy/turn/iallocation.h:86

Deleted constructor.


{#iallocation-3}

IAllocation

IAllocation(IAllocation &&) = delete

Defined in src/turn/include/icy/turn/iallocation.h:88

Deleted constructor.


{#updateusage}

updateUsage

virtual

virtual void updateUsage(std::int64_t numBytes = 0)

Defined in src/turn/include/icy/turn/iallocation.h:94

Updates the last-activity timestamp and accumulates bandwidth usage. Call this whenever data is relayed through the allocation.

Parameters

  • numBytes Number of bytes relayed (0 just refreshes the timestamp).

{#setlifetime}

setLifetime

virtual

virtual void setLifetime(std::int64_t lifetime)

Defined in src/turn/include/icy/turn/iallocation.h:99

Sets the allocation lifetime in seconds and resets the activity timestamp, effectively extending the expiry from the current moment.

Parameters

  • lifetime New lifetime in seconds.

{#setbandwidthlimit}

setBandwidthLimit

virtual

virtual void setBandwidthLimit(std::int64_t numBytes)

Defined in src/turn/include/icy/turn/iallocation.h:104

Sets the maximum number of bytes this allocation may relay in its lifetime. Pass 0 to disable bandwidth limiting.

Parameters

  • numBytes Bandwidth cap in bytes (0 = unlimited).

{#expired}

expired

virtual const nodiscard

[[nodiscard]] virtual bool expired() const

Defined in src/turn/include/icy/turn/iallocation.h:108

Returns

true if the allocation's lifetime has elapsed or the bandwidth quota has been exhausted.


{#deleted-1}

deleted

virtual const nodiscard

[[nodiscard]] virtual bool deleted() const

Defined in src/turn/include/icy/turn/iallocation.h:116

Returns true if the allocation's deleted flag is set and or if the allocation has expired.

This signifies that the allocation is ready to be destroyed via async garbage collection. See Server::onTimer() and Client::onTimer()


{#bandwidthlimit}

bandwidthLimit

virtual const nodiscard

[[nodiscard]] virtual std::int64_t bandwidthLimit() const

Defined in src/turn/include/icy/turn/iallocation.h:119

Returns

The configured bandwidth limit in bytes (0 means unlimited).


{#bandwidthused}

bandwidthUsed

virtual const nodiscard

[[nodiscard]] virtual std::int64_t bandwidthUsed() const

Defined in src/turn/include/icy/turn/iallocation.h:122

Returns

Total bytes transferred through this allocation since creation.


{#bandwidthremaining}

bandwidthRemaining

virtual const nodiscard

[[nodiscard]] virtual std::int64_t bandwidthRemaining() const

Defined in src/turn/include/icy/turn/iallocation.h:126

Returns

Bytes remaining before the bandwidth quota is exhausted. Returns a large sentinel value when no limit is configured.


{#timeremaining}

timeRemaining

virtual const nodiscard

[[nodiscard]] virtual std::int64_t timeRemaining() const

Defined in src/turn/include/icy/turn/iallocation.h:129

Returns

Seconds until the allocation expires (0 if already expired).

Reimplemented by

{#tuple}

tuple

virtual

virtual FiveTuple & tuple()

Defined in src/turn/include/icy/turn/iallocation.h:132

Returns

Reference to the 5-tuple identifying this allocation.


{#username-3}

username

virtual const nodiscard

[[nodiscard]] virtual std::string username() const

Defined in src/turn/include/icy/turn/iallocation.h:135

Returns

The username associated with this allocation.


{#lifetime-1}

lifetime

virtual const nodiscard

[[nodiscard]] virtual std::int64_t lifetime() const

Defined in src/turn/include/icy/turn/iallocation.h:138

Returns

The configured lifetime in seconds.


{#permissions}

permissions

virtual const nodiscard

[[nodiscard]] virtual PermissionList permissions() const

Defined in src/turn/include/icy/turn/iallocation.h:141

Returns

A copy of the current permission list.


{#relayedaddress-1}

relayedAddress

virtual const nodiscard

[[nodiscard]] virtual net::Address relayedAddress() const

Defined in src/turn/include/icy/turn/iallocation.h:144

Returns

The relay transport address assigned to this allocation.

Reimplemented by

{#addpermission-3}

addPermission

virtual

virtual void addPermission(const std::string & ip)

Defined in src/turn/include/icy/turn/iallocation.h:148

Adds a permission for ip, or refreshes the existing one.

Parameters

  • ip IPv4 address string to permit.
Reimplemented by

{#addpermission-4}

addPermission

virtual

virtual void addPermission(const net::Address & address)

Defined in src/turn/include/icy/turn/iallocation.h:152

Adds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only.

Reimplemented by

{#addpermissions}

addPermissions

virtual

virtual void addPermissions(const IPList & ips)

Defined in src/turn/include/icy/turn/iallocation.h:156

Adds (or refreshes) permissions for multiple IPs.

Parameters

  • ips List of IPv4 address strings.

{#removepermission-2}

removePermission

virtual

virtual void removePermission(const std::string & ip)

Defined in src/turn/include/icy/turn/iallocation.h:160

Removes the permission for ip if present.

Parameters

  • ip IPv4 address string to remove.
Reimplemented by

{#removepermission-3}

removePermission

virtual

virtual void removePermission(const net::Address & address)

Defined in src/turn/include/icy/turn/iallocation.h:164

Removes the permission for address if present. The port is ignored; TURN permissions are IP-only.

Reimplemented by

{#removeallpermissions}

removeAllPermissions

virtual

virtual void removeAllPermissions()

Defined in src/turn/include/icy/turn/iallocation.h:167

Removes all permissions from the list.


{#removeexpiredpermissions}

removeExpiredPermissions

virtual

virtual void removeExpiredPermissions()

Defined in src/turn/include/icy/turn/iallocation.h:170

Removes any permissions whose 5-minute lifetime has elapsed.


{#haspermission-2}

hasPermission

virtual nodiscard

[[nodiscard]] virtual bool hasPermission(const std::string & peerIP)

Defined in src/turn/include/icy/turn/iallocation.h:176

Checks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted.

Parameters

  • peerIP IPv4 address string to check.

Returns

true if a valid (non-expired) permission exists.

Reimplemented by

{#haspermission-3}

hasPermission

virtual nodiscard

[[nodiscard]] virtual bool hasPermission(const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/iallocation.h:180

Checks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.

Reimplemented by

{#print-11}

print

virtual const inline

virtual inline void print(std::ostream & os) const

Defined in src/turn/include/icy/turn/iallocation.h:182

Reimplemented by

Protected Attributes

ReturnNameDescription
FiveTuple_tuple
std::string_username
PermissionList_permissions
std::int64_t_lifetime
std::int64_t_bandwidthLimit
std::int64_t_bandwidthUsed
time_t_createdAt
time_t_updatedAt
bool_deleted

{#_tuple}

_tuple

FiveTuple _tuple

Defined in src/turn/include/icy/turn/iallocation.h:195


{#_username-2}

_username

std::string _username

Defined in src/turn/include/icy/turn/iallocation.h:196


{#_permissions}

_permissions

PermissionList _permissions

Defined in src/turn/include/icy/turn/iallocation.h:197


{#_lifetime}

_lifetime

std::int64_t _lifetime

Defined in src/turn/include/icy/turn/iallocation.h:198


{#_bandwidthlimit}

_bandwidthLimit

std::int64_t _bandwidthLimit

Defined in src/turn/include/icy/turn/iallocation.h:199


{#_bandwidthused}

_bandwidthUsed

std::int64_t _bandwidthUsed

Defined in src/turn/include/icy/turn/iallocation.h:200


{#_createdat}

_createdAt

time_t _createdAt

Defined in src/turn/include/icy/turn/iallocation.h:201


{#_updatedat}

_updatedAt

time_t _updatedAt

Defined in src/turn/include/icy/turn/iallocation.h:202


{#_deleted}

_deleted

bool _deleted

Defined in src/turn/include/icy/turn/iallocation.h:203

{#permissionpolicy}

PermissionPolicy

#include <icy/turn/server/permissionpolicy.h>
class PermissionPolicy

Defined in src/turn/include/icy/turn/server/permissionpolicy.h:25

Lightweight server-side TURN permission policy.

Keeps the explicit permission list fast and binary, while making server exceptions such as local-IP auto-grants explicit and auditable.

List of all members

NameKindOwner
PermissionPolicyfunctionDeclared here
allowsExplicitfunctionDeclared here
allowsImplicitfunctionDeclared here
allowsfunctionDeclared here
_enableLocalIPPermissionsvariableDeclared here
isLocalAutoGrantAddressfunctionDeclared here

Public Methods

ReturnNameDescription
PermissionPolicy inline explicit noexcept
boolallowsExplicit const nodiscard noexcept
boolallowsImplicit const nodiscard noexcept
boolallows const nodiscard noexcept

{#permissionpolicy-1}

PermissionPolicy

inline explicit noexcept

inline explicit PermissionPolicy(bool enableLocalIPPermissions = false) noexcept

Defined in src/turn/include/icy/turn/server/permissionpolicy.h:28


{#allowsexplicit}

allowsExplicit

const nodiscard noexcept

[[nodiscard]] bool allowsExplicit(const PermissionList & permissions, const Permission::Key & peerKey) const noexcept

Defined in src/turn/include/icy/turn/server/permissionpolicy.h:33


{#allowsimplicit}

allowsImplicit

const nodiscard noexcept

[[nodiscard]] bool allowsImplicit(const Permission::Key & peerKey) const noexcept

Defined in src/turn/include/icy/turn/server/permissionpolicy.h:35


{#allows}

allows

const nodiscard noexcept

[[nodiscard]] bool allows(const PermissionList & permissions, const Permission::Key & peerKey) const noexcept

Defined in src/turn/include/icy/turn/server/permissionpolicy.h:36

Private Attributes

ReturnNameDescription
bool_enableLocalIPPermissions

{#_enablelocalippermissions}

_enableLocalIPPermissions

bool _enableLocalIPPermissions = false

Defined in src/turn/include/icy/turn/server/permissionpolicy.h:42

Private Static Methods

ReturnNameDescription
boolisLocalAutoGrantAddress static nodiscard noexcept

{#islocalautograntaddress}

isLocalAutoGrantAddress

static nodiscard noexcept

[[nodiscard]] static bool isLocalAutoGrantAddress(const Permission::Key & peerKey) noexcept

Defined in src/turn/include/icy/turn/server/permissionpolicy.h:40

{#request-12}

Request

#include <icy/turn/types.h>
class Request

Defined in src/turn/include/icy/turn/types.h:61

Inherits: Message

A STUN message annotated with the transport type and source/destination addresses needed for server-side routing and response generation.

List of all members

NameKindOwner
transportvariableDeclared here
localAddressvariableDeclared here
remoteAddressvariableDeclared here
hashvariableDeclared here
RequestfunctionDeclared here
MessagefunctionInherited from Message
MessagefunctionInherited from Message
MessagefunctionInherited from Message
MessagefunctionInherited from Message
operator=functionInherited from Message
operator=functionInherited from Message
clonefunctionInherited from Message
setClassfunctionInherited from Message
setMethodfunctionInherited from Message
setTransactionIDfunctionInherited from Message
classTypefunctionInherited from Message
methodTypefunctionInherited from Message
transactionIDfunctionInherited from Message
sizefunctionInherited from Message
methodStringfunctionInherited from Message
classStringfunctionInherited from Message
errorStringfunctionInherited from Message
addfunctionInherited from Message
addfunctionInherited from Message
getfunctionInherited from Message
getfunctionInherited from Message
readfunctionInherited from Message
writefunctionInherited from Message
toStringfunctionInherited from Message
printfunctionInherited from Message
classNamefunctionInherited from Message
_classvariableInherited from Message
_methodvariableInherited from Message
_sizevariableInherited from Message
_transactionIDvariableInherited from Message
_attrsvariableInherited from Message
MethodTypeenumInherited from Message
ClassTypeenumInherited from Message
ErrorCodesenumInherited from Message
computeBodySizefunctionInherited from Message
opaquevariableInherited from IPacket
infovariableInherited from IPacket
flagsvariableInherited from IPacket
IPacketfunctionInherited from IPacket
IPacketfunctionInherited from IPacket
operator=functionInherited from IPacket
clonefunctionInherited from IPacket
~IPacketfunctionInherited from IPacket
readfunctionInherited from IPacket
writefunctionInherited from IPacket
sizefunctionInherited from IPacket
hasDatafunctionInherited from IPacket
datafunctionInherited from IPacket
constDatafunctionInherited from IPacket
classNamefunctionInherited from IPacket
printfunctionInherited from IPacket
operator<<friendInherited from IPacket

Inherited from Message

KindNameDescription
functionMessageConstructs a default message (Request class, Undefined method) with a randomly generated 12-byte transaction ID.
functionMessageConstructs a message with explicit class and method.
functionMessageDeep-copy constructor; clones all attributes.
functionMessage noexceptMove constructor.
functionoperator=Deep-copy assignment; clones all attributes from that.
functionoperator= noexceptMove assignment.
functionclone virtual const override
functionsetClassSets the message class field.
functionsetMethodSets the message method field.
functionsetTransactionIDSets the 12-byte transaction ID.
functionclassType const nodiscard
functionmethodType const nodiscard
functiontransactionID const inline nodiscard
functionsize virtual const inline nodiscard override
functionmethodString const nodiscard
functionclassString const nodiscard
functionerrorString const nodiscardMaps a numeric error code to its canonical string description.
functionadd inlineConstructs an attribute of type T in-place and appends it to the message. Returns a reference to the new attribute for further configuration.
functionaddAppends an attribute to the message, taking ownership via unique_ptr.
functionget const nodiscardReturns the Nth attribute of the given type, or nullptr if not found.
functionget const inline nodiscardType-safe attribute accessor using the concrete attribute's TypeID.
functionread virtual overrideParses a STUN/TURN packet from the given buffer.
functionwrite virtual const overrideSerialises this message into a STUN/TURN wire-format packet.
functiontoString const nodiscard
functionprint virtual const overrideWrites the same representation as toString() to the given stream.
functionclassName virtual const inline overrideReturns the class name of this packet type for logging and diagnostics.
variable_class
variable_method
variable_sizeSet by read(); write() uses computeBodySize() instead.
variable_transactionID
variable_attrs
enumMethodType
enumClassType
enumErrorCodes
functioncomputeBodySize const nodiscardComputes the wire body size from the current attribute list.

Inherited from IPacket

KindNameDescription
variableopaqueOptional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime.
variableinfoOptional extra information about the packet.
variableflagsProvides basic information about the packet.
functionIPacket inline
functionIPacket inlineCopy constructor; clones the info object if present.
functionoperator= inlineCopy assignment; clones the info object if present.
functionclone virtual constReturns a heap-allocated deep copy of this packet.
function~IPacket virtualDefaulted destructor.
functionread virtualRead/parse to the packet from the given input buffer. The number of bytes read is returned.
functionwrite virtual constCopy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer.
functionsize virtual const inlineThe size of the packet in bytes.
functionhasData virtual const inlineReturns true if the packet has a non-null data pointer.
functiondata virtual const inlineThe packet data pointer for buffered packets.
functionconstData virtual const inlineThe const packet data pointer for buffered packets.
functionclassName virtual constReturns the class name of this packet type for logging and diagnostics.
functionprint virtual const inlinePrints a human-readable representation to the given stream.
friendoperator<< inlineStream insertion operator; delegates to print().

Public Attributes

ReturnNameDescription
net::TransportTypetransportProtocol on which the request arrived (UDP or TCP).
net::AddresslocalAddressServer's local address that received the request.
net::AddressremoteAddressClient's remote address (used to build the 5-tuple).
std::stringhashPre-computed MessageIntegrity key for signing responses.

{#transport-6}

transport

net::TransportType transport

Defined in src/turn/include/icy/turn/types.h:64

Protocol on which the request arrived (UDP or TCP).


{#localaddress}

localAddress

net::Address localAddress

Defined in src/turn/include/icy/turn/types.h:65

Server's local address that received the request.


{#remoteaddress}

remoteAddress

net::Address remoteAddress

Defined in src/turn/include/icy/turn/types.h:66

Client's remote address (used to build the 5-tuple).


{#hash}

hash

std::string hash

Defined in src/turn/include/icy/turn/types.h:67

Pre-computed MessageIntegrity key for signing responses.

Public Methods

ReturnNameDescription
Request inlineConstructs a Request by copying a parsed STUN message and annotating it with the transport context.

{#request-13}

Request

inline

inline Request(const stun::Message & message, net::TransportType transport, const net::Address & localAddress = net::Address(), const net::Address & remoteAddress = net::Address())

Defined in src/turn/include/icy/turn/types.h:75

Constructs a Request by copying a parsed STUN message and annotating it with the transport context.

Parameters

  • message Parsed STUN message.

  • transport Transport protocol on which the message arrived.

  • localAddress Server-side local address.

  • remoteAddress Client-side remote address.

{#server-6}

Server

#include <icy/turn/server/server.h>
class Server

Defined in src/turn/include/icy/turn/server/server.h:126

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.

List of all members

NameKindOwner
ServerfunctionDeclared here
startfunctionDeclared here
stopfunctionDeclared here
handleRequestfunctionDeclared here
handleAuthorizedRequestfunctionDeclared here
handleBindingRequestfunctionDeclared here
handleAllocateRequestfunctionDeclared here
handleConnectionBindRequestfunctionDeclared here
respondfunctionDeclared here
respondErrorfunctionDeclared here
allocationsfunctionDeclared here
addAllocationfunctionDeclared here
removeAllocationfunctionDeclared here
getAllocationfunctionDeclared here
getTCPAllocationfunctionDeclared here
getTCPSocketfunctionDeclared here
releaseTCPSocketfunctionDeclared here
observerfunctionDeclared here
optionsfunctionDeclared here
udpSocketfunctionDeclared here
tcpSocketfunctionDeclared here
timerfunctionDeclared here
onTCPAcceptConnectionfunctionDeclared here
onTCPSocketClosedfunctionDeclared here
onSocketRecvfunctionDeclared here
onTimerfunctionDeclared here
scheduleDeferredTCPSocketReleasefunctionDeclared here
drainReleasedTCPSocketsfunctionDeclared here
_mutexvariableDeclared here
_observervariableDeclared here
_optionsvariableDeclared here
_udpSocketvariableDeclared here
_tcpSocketvariableDeclared here
_tcpSocketsvariableDeclared here
_pendingReleasedTCPSocketsvariableDeclared here
_tcpSocketReleaseScheduledvariableDeclared here
_allocationsvariableDeclared here
_timervariableDeclared here

Public Methods

ReturnNameDescription
Server
voidstart virtualBinds and listens on the configured address, then starts the maintenance timer.
voidstop virtualStops the timer, destroys all allocations, and closes server sockets.
voidhandleRequestRoutes an authenticated request to the appropriate handler based on state. Pending (Authenticating) requests are held until the observer calls back.
voidhandleAuthorizedRequestDispatches an already-authorized request to the specific method handler.
voidhandleBindingRequestHandles a Binding request; responds with XOR-MAPPED-ADDRESS.
voidhandleAllocateRequestHandles an Allocate request; creates a UDP or TCP ServerAllocation and sends a success response with XOR-RELAYED-ADDRESS and LIFETIME.
voidhandleConnectionBindRequestHandles a ConnectionBind request by locating the TCPAllocation that owns the given CONNECTION-ID and delegating to it.
voidrespondSends a STUN response, signing it with MessageIntegrity if the request had a hash. Routes via UDP or TCP depending on request.transport.
voidrespondErrorConstructs and sends an error response with SOFTWARE, REALM, NONCE, and ERROR-CODE.
std::map< FiveTuple, ServerAllocation * >allocations constReturns a snapshot copy of the allocation map for safe iteration. Returned raw pointers are valid only while the server holds the allocations.
voidaddAllocationTransfers ownership of alloc to the server and notifies the observer.
voidremoveAllocationRemoves alloc from the map and notifies the observer. Called automatically from the ServerAllocation destructor.
ServerAllocation *getAllocation nodiscardLooks up an allocation by its 5-tuple.
TCPAllocation *getTCPAllocation nodiscardFinds the TCPAllocation that owns a TCPConnectionPair with the given connection ID.
net::TCPSocket::PtrgetTCPSocket nodiscardReturns the accepted TCP socket whose peer address matches remoteAddr.
voidreleaseTCPSocketRemoves a TCP control socket from the server's socket list and unregisters callbacks. Called when the socket is handed off to a TCPAllocation (ConnectionBind).
ServerObserver &observer
const ServerOptions &options const nodiscard
net::UDPSocket &udpSocket
net::TCPSocket &tcpSocket
Timer &timer
voidonTCPAcceptConnectionAccept callback for the TCP listening socket; registers new connections for STUN message processing.
boolonTCPSocketClosedClose callback for accepted TCP sockets; removes the socket from the list.
boolonSocketRecvReceive callback for both UDP and TCP sockets; parses STUN messages and calls handleRequest() for each one.
voidonTimerPeriodic maintenance callback; expires and removes stale allocations.
voidscheduleDeferredTCPSocketReleaseDefers accepted TCP socket removal until after the active callback stack unwinds.
voiddrainReleasedTCPSockets

{#server-7}

Server

Server(ServerObserver & observer, const ServerOptions & options = ServerOptions())

Defined in src/turn/include/icy/turn/server/server.h:131

Parameters

  • observer Observer used for authentication and allocation lifecycle events.

  • options Server configuration; defaults to 0.0.0.0:3478 with TCP and UDP enabled.


{#start-14}

start

virtual

virtual void start()

Defined in src/turn/include/icy/turn/server/server.h:135

Binds and listens on the configured address, then starts the maintenance timer.


{#stop-11}

stop

virtual

virtual void stop()

Defined in src/turn/include/icy/turn/server/server.h:138

Stops the timer, destroys all allocations, and closes server sockets.


{#handlerequest}

handleRequest

void handleRequest(Request & request, AuthenticationState state)

Defined in src/turn/include/icy/turn/server/server.h:144

Routes an authenticated request to the appropriate handler based on state. Pending (Authenticating) requests are held until the observer calls back.

Parameters

  • request Incoming STUN request.

  • state Result of the observer's authenticateRequest() call.


{#handleauthorizedrequest}

handleAuthorizedRequest

void handleAuthorizedRequest(Request & request)

Defined in src/turn/include/icy/turn/server/server.h:148

Dispatches an already-authorized request to the specific method handler.

Parameters

  • request Authorized STUN request.

{#handlebindingrequest}

handleBindingRequest

void handleBindingRequest(Request & request)

Defined in src/turn/include/icy/turn/server/server.h:152

Handles a Binding request; responds with XOR-MAPPED-ADDRESS.

Parameters

  • request Incoming Binding request.

{#handleallocaterequest}

handleAllocateRequest

void handleAllocateRequest(Request & request)

Defined in src/turn/include/icy/turn/server/server.h:157

Handles an Allocate request; creates a UDP or TCP ServerAllocation and sends a success response with XOR-RELAYED-ADDRESS and LIFETIME.

Parameters

  • request Incoming Allocate request.

{#handleconnectionbindrequest}

handleConnectionBindRequest

void handleConnectionBindRequest(Request & request)

Defined in src/turn/include/icy/turn/server/server.h:162

Handles a ConnectionBind request by locating the TCPAllocation that owns the given CONNECTION-ID and delegating to it.

Parameters

  • request Incoming ConnectionBind request.

{#respond}

respond

void respond(Request & request, stun::Message & response)

Defined in src/turn/include/icy/turn/server/server.h:168

Sends a STUN response, signing it with MessageIntegrity if the request had a hash. Routes via UDP or TCP depending on request.transport.

Parameters

  • request The original request (provides transport and remote address).

  • response The response message to send.


{#responderror}

respondError

void respondError(Request & request, int errorCode, const char * errorDesc)

Defined in src/turn/include/icy/turn/server/server.h:174

Constructs and sends an error response with SOFTWARE, REALM, NONCE, and ERROR-CODE.

Parameters

  • request The original request.

  • errorCode STUN error code (e.g. 400, 401, 437).

  • errorDesc Human-readable error description string.


{#allocations}

allocations

const

std::map< FiveTuple, ServerAllocation * > allocations() const

Defined in src/turn/include/icy/turn/server/server.h:179

Returns a snapshot copy of the allocation map for safe iteration. Returned raw pointers are valid only while the server holds the allocations.

Returns

Map from FiveTuple to raw ServerAllocation pointers.


{#addallocation}

addAllocation

void addAllocation(std::unique_ptr< ServerAllocation > alloc)

Defined in src/turn/include/icy/turn/server/server.h:183

Transfers ownership of alloc to the server and notifies the observer.

Parameters

  • alloc Newly constructed allocation to register.

{#removeallocation}

removeAllocation

void removeAllocation(ServerAllocation * alloc)

Defined in src/turn/include/icy/turn/server/server.h:188

Removes alloc from the map and notifies the observer. Called automatically from the ServerAllocation destructor.

Parameters

  • alloc Allocation being destroyed.

{#getallocation}

getAllocation

nodiscard

[[nodiscard]] ServerAllocation * getAllocation(const FiveTuple & tuple)

Defined in src/turn/include/icy/turn/server/server.h:193

Looks up an allocation by its 5-tuple.

Parameters

  • tuple The 5-tuple to search for.

Returns

Pointer to the matching allocation, or nullptr if not found.


{#gettcpallocation}

getTCPAllocation

nodiscard

[[nodiscard]] TCPAllocation * getTCPAllocation(const uint32_t & connectionID)

Defined in src/turn/include/icy/turn/server/server.h:198

Finds the TCPAllocation that owns a TCPConnectionPair with the given connection ID.

Parameters

  • connectionID TURN CONNECTION-ID to search for.

Returns

Pointer to the owning TCPAllocation, or nullptr if not found.


{#gettcpsocket}

getTCPSocket

nodiscard

[[nodiscard]] net::TCPSocket::Ptr getTCPSocket(const net::Address & remoteAddr)

Defined in src/turn/include/icy/turn/server/server.h:203

Returns the accepted TCP socket whose peer address matches remoteAddr.

Parameters

  • remoteAddr Peer address to search for.

Returns

Shared pointer to the socket, or empty if not found.


{#releasetcpsocket}

releaseTCPSocket

void releaseTCPSocket(const net::Socket & socket)

Defined in src/turn/include/icy/turn/server/server.h:208

Removes a TCP control socket from the server's socket list and unregisters callbacks. Called when the socket is handed off to a TCPAllocation (ConnectionBind).

Parameters

  • socket The socket to release.

{#observer-2}

observer

ServerObserver & observer()

Defined in src/turn/include/icy/turn/server/server.h:211

Returns

Reference to the observer provided at construction.


{#options-11}

options

const nodiscard

[[nodiscard]] const ServerOptions & options() const

Defined in src/turn/include/icy/turn/server/server.h:214

Returns

Reference to the immutable options struct.


{#udpsocket-4}

udpSocket

net::UDPSocket & udpSocket()

Defined in src/turn/include/icy/turn/server/server.h:217

Returns

Reference to the UDP server socket.


{#tcpsocket-4}

tcpSocket

net::TCPSocket & tcpSocket()

Defined in src/turn/include/icy/turn/server/server.h:220

Returns

Reference to the TCP server listening socket.


{#timer-1}

timer

Timer & timer()

Defined in src/turn/include/icy/turn/server/server.h:223

Returns

Reference to the maintenance timer.


{#ontcpacceptconnection}

onTCPAcceptConnection

void onTCPAcceptConnection(const net::TCPSocket::Ptr & sock)

Defined in src/turn/include/icy/turn/server/server.h:228

Accept callback for the TCP listening socket; registers new connections for STUN message processing.

Parameters

  • sock Newly accepted TCP socket.

{#ontcpsocketclosed}

onTCPSocketClosed

bool onTCPSocketClosed(net::Socket & socket)

Defined in src/turn/include/icy/turn/server/server.h:232

Close callback for accepted TCP sockets; removes the socket from the list.

Parameters

  • socket The closed socket.

{#onsocketrecv-8}

onSocketRecv

bool onSocketRecv(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/server/server.h:239

Receive callback for both UDP and TCP sockets; parses STUN messages and calls handleRequest() for each one.

Parameters

  • socket The receiving socket.

  • buffer Received data buffer.

  • peerAddress Source address of the data.


{#ontimer-3}

onTimer

void onTimer()

Defined in src/turn/include/icy/turn/server/server.h:243

Periodic maintenance callback; expires and removes stale allocations.


{#scheduledeferredtcpsocketrelease}

scheduleDeferredTCPSocketRelease

void scheduleDeferredTCPSocketRelease()

Defined in src/turn/include/icy/turn/server/server.h:246

Defers accepted TCP socket removal until after the active callback stack unwinds.


{#drainreleasedtcpsockets}

drainReleasedTCPSockets

void drainReleasedTCPSockets()

Defined in src/turn/include/icy/turn/server/server.h:247

Private Attributes

ReturnNameDescription
std::mutex_mutex
ServerObserver &_observer
ServerOptions_options
net::SocketEmitter_udpSocket
net::SocketEmitter_tcpSocket
std::vector< net::SocketEmitter >_tcpSockets
std::unordered_set< const net::Socket * >_pendingReleasedTCPSockets
bool_tcpSocketReleaseScheduled
ServerAllocationMap_allocations
Timer_timer

{#_mutex-13}

_mutex

std::mutex _mutex

Defined in src/turn/include/icy/turn/server/server.h:250


{#_observer-2}

_observer

ServerObserver & _observer

Defined in src/turn/include/icy/turn/server/server.h:251


{#_options-4}

_options

ServerOptions _options

Defined in src/turn/include/icy/turn/server/server.h:252


{#_udpsocket}

_udpSocket

net::SocketEmitter _udpSocket

Defined in src/turn/include/icy/turn/server/server.h:253


{#_tcpsocket}

_tcpSocket

net::SocketEmitter _tcpSocket

Defined in src/turn/include/icy/turn/server/server.h:254


{#_tcpsockets}

_tcpSockets

std::vector< net::SocketEmitter > _tcpSockets

Defined in src/turn/include/icy/turn/server/server.h:255


{#_pendingreleasedtcpsockets}

_pendingReleasedTCPSockets

std::unordered_set< const net::Socket * > _pendingReleasedTCPSockets

Defined in src/turn/include/icy/turn/server/server.h:256


{#_tcpsocketreleasescheduled}

_tcpSocketReleaseScheduled

bool _tcpSocketReleaseScheduled {false}

Defined in src/turn/include/icy/turn/server/server.h:257


{#_allocations}

_allocations

ServerAllocationMap _allocations

Defined in src/turn/include/icy/turn/server/server.h:258


{#_timer-2}

_timer

Timer _timer

Defined in src/turn/include/icy/turn/server/server.h:259

{#serverallocation}

ServerAllocation

#include <icy/turn/server/serverallocation.h>
class ServerAllocation

Defined in src/turn/include/icy/turn/server/serverallocation.h:29

Inherits: IAllocation Subclassed by: TCPAllocation, UDPAllocation

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.

List of all members

NameKindOwner
ServerfriendDeclared here
ServerAllocationfunctionDeclared here
handleRequestfunctionDeclared here
handleRefreshRequestfunctionDeclared here
handleCreatePermissionfunctionDeclared here
onTimerfunctionDeclared here
timeRemainingfunctionDeclared here
maxTimeRemainingfunctionDeclared here
hasPermissionfunctionDeclared here
hasPermissionfunctionDeclared here
serverfunctionDeclared here
printfunctionDeclared here
refreshDeleteRequestedfunctionDeclared here
_maxLifetimevariableDeclared here
_servervariableDeclared here
_permissionPolicyvariableDeclared here
_refreshDeleteRequestedvariableDeclared here
ServerAllocationfunctionDeclared here
ServerAllocationfunctionDeclared here
operator<<friendInherited from IAllocation
IAllocationfunctionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
updateUsagefunctionInherited from IAllocation
setLifetimefunctionInherited from IAllocation
setBandwidthLimitfunctionInherited from IAllocation
expiredfunctionInherited from IAllocation
deletedfunctionInherited from IAllocation
bandwidthLimitfunctionInherited from IAllocation
bandwidthUsedfunctionInherited from IAllocation
bandwidthRemainingfunctionInherited from IAllocation
timeRemainingfunctionInherited from IAllocation
tuplefunctionInherited from IAllocation
usernamefunctionInherited from IAllocation
lifetimefunctionInherited from IAllocation
permissionsfunctionInherited from IAllocation
relayedAddressfunctionInherited from IAllocation
addPermissionfunctionInherited from IAllocation
addPermissionfunctionInherited from IAllocation
addPermissionsfunctionInherited from IAllocation
removePermissionfunctionInherited from IAllocation
removePermissionfunctionInherited from IAllocation
removeAllPermissionsfunctionInherited from IAllocation
removeExpiredPermissionsfunctionInherited from IAllocation
hasPermissionfunctionInherited from IAllocation
hasPermissionfunctionInherited from IAllocation
printfunctionInherited from IAllocation
_tuplevariableInherited from IAllocation
_usernamevariableInherited from IAllocation
_permissionsvariableInherited from IAllocation
_lifetimevariableInherited from IAllocation
_bandwidthLimitvariableInherited from IAllocation
_bandwidthUsedvariableInherited from IAllocation
_createdAtvariableInherited from IAllocation
_updatedAtvariableInherited from IAllocation
_deletedvariableInherited from IAllocation

Inherited from IAllocation

KindNameDescription
friendoperator<< inline
functionIAllocation
functionIAllocationDeleted constructor.
functionIAllocationDeleted constructor.
functionupdateUsage virtualUpdates the last-activity timestamp and accumulates bandwidth usage. Call this whenever data is relayed through the allocation.
functionsetLifetime virtualSets the allocation lifetime in seconds and resets the activity timestamp, effectively extending the expiry from the current moment.
functionsetBandwidthLimit virtualSets the maximum number of bytes this allocation may relay in its lifetime. Pass 0 to disable bandwidth limiting.
functionexpired virtual const nodiscard
functiondeleted virtual const nodiscardReturns true if the allocation's deleted flag is set and or if the allocation has expired.
functionbandwidthLimit virtual const nodiscard
functionbandwidthUsed virtual const nodiscard
functionbandwidthRemaining virtual const nodiscard
functiontimeRemaining virtual const nodiscard
functiontuple virtual
functionusername virtual const nodiscard
functionlifetime virtual const nodiscard
functionpermissions virtual const nodiscard
functionrelayedAddress virtual const nodiscard
functionaddPermission virtualAdds a permission for ip, or refreshes the existing one.
functionaddPermission virtualAdds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only.
functionaddPermissions virtualAdds (or refreshes) permissions for multiple IPs.
functionremovePermission virtualRemoves the permission for ip if present.
functionremovePermission virtualRemoves the permission for address if present. The port is ignored; TURN permissions are IP-only.
functionremoveAllPermissions virtualRemoves all permissions from the list.
functionremoveExpiredPermissions virtualRemoves any permissions whose 5-minute lifetime has elapsed.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
functionprint virtual const inline
variable_tuple
variable_username
variable_permissions
variable_lifetime
variable_bandwidthLimit
variable_bandwidthUsed
variable_createdAt
variable_updatedAt
variable_deleted

Friends

NameDescription
Server

{#server-8}

Server

friend class Server

Defined in src/turn/include/icy/turn/server/serverallocation.h:84

Public Methods

ReturnNameDescription
ServerAllocation
boolhandleRequest virtualDispatches incoming STUN requests to handleCreatePermission() or handleRefreshRequest(). Subclasses override to add transport-specific methods.
voidhandleRefreshRequest virtualProcesses a Refresh request; updates the lifetime or sets the delete flag if the requested lifetime is 0, then sends a success response.
voidhandleCreatePermission virtualProcesses a CreatePermission request; installs or refreshes permissions for each XOR-PEER-ADDRESS attribute, then sends a success response.
boolonTimer nodiscardPeriodic maintenance callback called by Server::onTimer(). Removes expired permissions. Returns false to signal that this allocation should be destroyed.
std::int64_ttimeRemaining virtual const nodiscard override
std::int64_tmaxTimeRemaining const nodiscard
boolhasPermission virtual nodiscard overrideChecks permission, auto-granting local IPs if enabled in server options.
boolhasPermission virtual nodiscard overrideChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
Server &server virtual
voidprint virtual const overrideWrites a detailed diagnostic dump of this allocation to os.
boolrefreshDeleteRequested const inline nodiscardReturns true if the refresh request set lifetime to 0, signaling the parent Server to delete this allocation.

{#serverallocation-1}

ServerAllocation

ServerAllocation(Server & server, const FiveTuple & tuple, const std::string & username, std::int64_t lifetime)

Defined in src/turn/include/icy/turn/server/serverallocation.h:36

Parameters

  • server Owning TURN server.

  • tuple 5-tuple uniquely identifying this allocation.

  • username Authenticated username from the Allocate request.

  • lifetime Initial lifetime in seconds as negotiated with the client.


{#handlerequest-1}

handleRequest

virtual

virtual bool handleRequest(Request & request)

Defined in src/turn/include/icy/turn/server/serverallocation.h:45

Dispatches incoming STUN requests to handleCreatePermission() or handleRefreshRequest(). Subclasses override to add transport-specific methods.

Parameters

  • request Incoming STUN request.

Returns

true if the request was handled; false signals the server to respond with a 600 "Operation Not Supported" error.

Reimplemented by

{#handlerefreshrequest}

handleRefreshRequest

virtual

virtual void handleRefreshRequest(Request & request)

Defined in src/turn/include/icy/turn/server/serverallocation.h:50

Processes a Refresh request; updates the lifetime or sets the delete flag if the requested lifetime is 0, then sends a success response.

Parameters

  • request Incoming Refresh request.

{#handlecreatepermission}

handleCreatePermission

virtual

virtual void handleCreatePermission(Request & request)

Defined in src/turn/include/icy/turn/server/serverallocation.h:55

Processes a CreatePermission request; installs or refreshes permissions for each XOR-PEER-ADDRESS attribute, then sends a success response.

Parameters

  • request Incoming CreatePermission request.

{#ontimer-4}

onTimer

nodiscard

[[nodiscard]] bool onTimer()

Defined in src/turn/include/icy/turn/server/serverallocation.h:61

Periodic maintenance callback called by Server::onTimer(). Removes expired permissions. Returns false to signal that this allocation should be destroyed.

Returns

true to keep the allocation alive; false to destroy it.


{#timeremaining-1}

timeRemaining

virtual const nodiscard override

[[nodiscard]] virtual std::int64_t timeRemaining() const override

Defined in src/turn/include/icy/turn/server/serverallocation.h:64

Returns

The lesser of IAllocation::timeRemaining() and maxTimeRemaining().

Reimplements

{#maxtimeremaining}

maxTimeRemaining

const nodiscard

[[nodiscard]] std::int64_t maxTimeRemaining() const

Defined in src/turn/include/icy/turn/server/serverallocation.h:67

Returns

Seconds remaining before the server-enforced maximum lifetime expires.


{#haspermission-4}

hasPermission

virtual nodiscard override

[[nodiscard]] virtual bool hasPermission(const std::string & peerIP) override

Defined in src/turn/include/icy/turn/server/serverallocation.h:70

Checks permission, auto-granting local IPs if enabled in server options.

Reimplements

{#haspermission-5}

hasPermission

virtual nodiscard override

[[nodiscard]] virtual bool hasPermission(const net::Address & peerAddress) override

Defined in src/turn/include/icy/turn/server/serverallocation.h:71

Checks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.

Reimplements

{#server-9}

server

virtual

virtual Server & server()

Defined in src/turn/include/icy/turn/server/serverallocation.h:74

Returns

Reference to the owning TURN server.


{#print-12}

virtual const override

virtual void print(std::ostream & os) const override

Defined in src/turn/include/icy/turn/server/serverallocation.h:77

Writes a detailed diagnostic dump of this allocation to os.

Reimplements

{#refreshdeleterequested}

refreshDeleteRequested

const inline nodiscard

[[nodiscard]] inline bool refreshDeleteRequested() const

Defined in src/turn/include/icy/turn/server/serverallocation.h:81

Returns true if the refresh request set lifetime to 0, signaling the parent Server to delete this allocation.

Protected Attributes

ReturnNameDescription
uint32_t_maxLifetime
Server &_server
PermissionPolicy_permissionPolicy
bool_refreshDeleteRequested

{#_maxlifetime}

_maxLifetime

uint32_t _maxLifetime

Defined in src/turn/include/icy/turn/server/serverallocation.h:86


{#_server-1}

_server

Server & _server

Defined in src/turn/include/icy/turn/server/serverallocation.h:87


{#_permissionpolicy}

_permissionPolicy

PermissionPolicy _permissionPolicy

Defined in src/turn/include/icy/turn/server/serverallocation.h:88


{#_refreshdeleterequested}

_refreshDeleteRequested

bool _refreshDeleteRequested = false

Defined in src/turn/include/icy/turn/server/serverallocation.h:89

Private Methods

ReturnNameDescription
ServerAllocationNonCopyable and NonMovable.
ServerAllocationDeleted constructor.

{#serverallocation-2}

ServerAllocation

ServerAllocation(const ServerAllocation &) = delete

Defined in src/turn/include/icy/turn/server/serverallocation.h:93

NonCopyable and NonMovable.


{#serverallocation-3}

ServerAllocation

ServerAllocation(ServerAllocation &&) = delete

Defined in src/turn/include/icy/turn/server/serverallocation.h:95

Deleted constructor.

{#tcpallocation}

TCPAllocation

#include <icy/turn/server/tcpallocation.h>
class TCPAllocation

Defined in src/turn/include/icy/turn/server/tcpallocation.h:36

Inherits: ServerAllocation

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.

List of all members

NameKindOwner
TCPAllocationfunctionDeclared here
handleRequestfunctionDeclared here
handleConnectRequestfunctionDeclared here
handleConnectionBindRequestfunctionDeclared here
sendPeerConnectResponsefunctionDeclared here
sendToControlfunctionDeclared here
controlfunctionDeclared here
relayedAddressfunctionDeclared here
pairsfunctionDeclared here
onTimerfunctionDeclared here
onPeerAcceptfunctionDeclared here
onControlClosedfunctionDeclared here
_controlvariableDeclared here
_acceptorvariableDeclared here
_pairsvariableDeclared here
ServerfriendInherited from ServerAllocation
ServerAllocationfunctionInherited from ServerAllocation
handleRequestfunctionInherited from ServerAllocation
handleRefreshRequestfunctionInherited from ServerAllocation
handleCreatePermissionfunctionInherited from ServerAllocation
onTimerfunctionInherited from ServerAllocation
timeRemainingfunctionInherited from ServerAllocation
maxTimeRemainingfunctionInherited from ServerAllocation
hasPermissionfunctionInherited from ServerAllocation
hasPermissionfunctionInherited from ServerAllocation
serverfunctionInherited from ServerAllocation
printfunctionInherited from ServerAllocation
refreshDeleteRequestedfunctionInherited from ServerAllocation
_maxLifetimevariableInherited from ServerAllocation
_servervariableInherited from ServerAllocation
_permissionPolicyvariableInherited from ServerAllocation
_refreshDeleteRequestedvariableInherited from ServerAllocation
ServerAllocationfunctionInherited from ServerAllocation
ServerAllocationfunctionInherited from ServerAllocation
operator<<friendInherited from IAllocation
IAllocationfunctionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
updateUsagefunctionInherited from IAllocation
setLifetimefunctionInherited from IAllocation
setBandwidthLimitfunctionInherited from IAllocation
expiredfunctionInherited from IAllocation
deletedfunctionInherited from IAllocation
bandwidthLimitfunctionInherited from IAllocation
bandwidthUsedfunctionInherited from IAllocation
bandwidthRemainingfunctionInherited from IAllocation
timeRemainingfunctionInherited from IAllocation
tuplefunctionInherited from IAllocation
usernamefunctionInherited from IAllocation
lifetimefunctionInherited from IAllocation
permissionsfunctionInherited from IAllocation
relayedAddressfunctionInherited from IAllocation
addPermissionfunctionInherited from IAllocation
addPermissionfunctionInherited from IAllocation
addPermissionsfunctionInherited from IAllocation
removePermissionfunctionInherited from IAllocation
removePermissionfunctionInherited from IAllocation
removeAllPermissionsfunctionInherited from IAllocation
removeExpiredPermissionsfunctionInherited from IAllocation
hasPermissionfunctionInherited from IAllocation
hasPermissionfunctionInherited from IAllocation
printfunctionInherited from IAllocation
_tuplevariableInherited from IAllocation
_usernamevariableInherited from IAllocation
_permissionsvariableInherited from IAllocation
_lifetimevariableInherited from IAllocation
_bandwidthLimitvariableInherited from IAllocation
_bandwidthUsedvariableInherited from IAllocation
_createdAtvariableInherited from IAllocation
_updatedAtvariableInherited from IAllocation
_deletedvariableInherited from IAllocation

Inherited from ServerAllocation

KindNameDescription
friendServer
functionServerAllocation
functionhandleRequest virtualDispatches incoming STUN requests to handleCreatePermission() or handleRefreshRequest(). Subclasses override to add transport-specific methods.
functionhandleRefreshRequest virtualProcesses a Refresh request; updates the lifetime or sets the delete flag if the requested lifetime is 0, then sends a success response.
functionhandleCreatePermission virtualProcesses a CreatePermission request; installs or refreshes permissions for each XOR-PEER-ADDRESS attribute, then sends a success response.
functiononTimer nodiscardPeriodic maintenance callback called by Server::onTimer(). Removes expired permissions. Returns false to signal that this allocation should be destroyed.
functiontimeRemaining virtual const nodiscard override
functionmaxTimeRemaining const nodiscard
functionhasPermission virtual nodiscard overrideChecks permission, auto-granting local IPs if enabled in server options.
functionhasPermission virtual nodiscard overrideChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
functionserver virtual
functionprint virtual const overrideWrites a detailed diagnostic dump of this allocation to os.
functionrefreshDeleteRequested const inline nodiscardReturns true if the refresh request set lifetime to 0, signaling the parent Server to delete this allocation.
variable_maxLifetime
variable_server
variable_permissionPolicy
variable_refreshDeleteRequested
functionServerAllocationNonCopyable and NonMovable.
functionServerAllocationDeleted constructor.

Inherited from IAllocation

KindNameDescription
friendoperator<< inline
functionIAllocation
functionIAllocationDeleted constructor.
functionIAllocationDeleted constructor.
functionupdateUsage virtualUpdates the last-activity timestamp and accumulates bandwidth usage. Call this whenever data is relayed through the allocation.
functionsetLifetime virtualSets the allocation lifetime in seconds and resets the activity timestamp, effectively extending the expiry from the current moment.
functionsetBandwidthLimit virtualSets the maximum number of bytes this allocation may relay in its lifetime. Pass 0 to disable bandwidth limiting.
functionexpired virtual const nodiscard
functiondeleted virtual const nodiscardReturns true if the allocation's deleted flag is set and or if the allocation has expired.
functionbandwidthLimit virtual const nodiscard
functionbandwidthUsed virtual const nodiscard
functionbandwidthRemaining virtual const nodiscard
functiontimeRemaining virtual const nodiscard
functiontuple virtual
functionusername virtual const nodiscard
functionlifetime virtual const nodiscard
functionpermissions virtual const nodiscard
functionrelayedAddress virtual const nodiscard
functionaddPermission virtualAdds a permission for ip, or refreshes the existing one.
functionaddPermission virtualAdds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only.
functionaddPermissions virtualAdds (or refreshes) permissions for multiple IPs.
functionremovePermission virtualRemoves the permission for ip if present.
functionremovePermission virtualRemoves the permission for address if present. The port is ignored; TURN permissions are IP-only.
functionremoveAllPermissions virtualRemoves all permissions from the list.
functionremoveExpiredPermissions virtualRemoves any permissions whose 5-minute lifetime has elapsed.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
functionprint virtual const inline
variable_tuple
variable_username
variable_permissions
variable_lifetime
variable_bandwidthLimit
variable_bandwidthUsed
variable_createdAt
variable_updatedAt
variable_deleted

Public Methods

ReturnNameDescription
TCPAllocation
boolhandleRequest virtualExtends the base handler with Connect and ConnectionBind methods.
voidhandleConnectRequestHandles a Connect request; creates a TCPConnectionPair and initiates a TCP connection to the peer address carried in XOR-PEER-ADDRESS.
voidhandleConnectionBindRequestHandles a ConnectionBind request; associates the incoming TCP data socket with the pending TCPConnectionPair and activates the relay pipe.
voidsendPeerConnectResponseSends a Connect success or failure response to the control connection.
ssize_tsendToControlSends a STUN message to the client over the control TCP connection.
net::TCPSocket &control
net::AddressrelayedAddress virtual const nodiscard
TCPConnectionPairMap &pairs
boolonTimerPeriodic timer callback; removes expired or pending-delete connection pairs, then calls the base class timer.
voidonPeerAcceptAccepts incoming peer sockets on the relay acceptor socket. Checks permissions and sends a ConnectionAttempt indication to the control.
boolonControlClosedCalled when the control connection closes; marks the allocation for deletion.

{#tcpallocation-1}

TCPAllocation

TCPAllocation(Server & server, const net::Socket::Ptr & control, const FiveTuple & tuple, const std::string & username, const uint32_t & lifetime)

Defined in src/turn/include/icy/turn/server/tcpallocation.h:44

Parameters

  • server Owning TURN server.

  • control The accepted TCP socket used for STUN control messages.

  • tuple 5-tuple identifying this allocation.

  • username Authenticated username from the Allocate request.

  • lifetime Initial lifetime in seconds.


{#handlerequest-2}

handleRequest

virtual

virtual bool handleRequest(Request & request)

Defined in src/turn/include/icy/turn/server/tcpallocation.h:52

Extends the base handler with Connect and ConnectionBind methods.

Parameters

  • request Incoming STUN request.

Returns

true if handled.

Reimplements

{#handleconnectrequest}

handleConnectRequest

void handleConnectRequest(Request & request)

Defined in src/turn/include/icy/turn/server/tcpallocation.h:57

Handles a Connect request; creates a TCPConnectionPair and initiates a TCP connection to the peer address carried in XOR-PEER-ADDRESS.

Parameters

  • request Incoming Connect request.

{#handleconnectionbindrequest-1}

handleConnectionBindRequest

void handleConnectionBindRequest(Request & request)

Defined in src/turn/include/icy/turn/server/tcpallocation.h:62

Handles a ConnectionBind request; associates the incoming TCP data socket with the pending TCPConnectionPair and activates the relay pipe.

Parameters

  • request Incoming ConnectionBind request.

{#sendpeerconnectresponse}

sendPeerConnectResponse

void sendPeerConnectResponse(TCPConnectionPair * pair, bool success)

Defined in src/turn/include/icy/turn/server/tcpallocation.h:67

Sends a Connect success or failure response to the control connection.

Parameters

  • pair The connection pair whose peer connection attempt completed.

  • success true if the peer TCP connection succeeded.


{#sendtocontrol}

sendToControl

ssize_t sendToControl(stun::Message & message)

Defined in src/turn/include/icy/turn/server/tcpallocation.h:72

Sends a STUN message to the client over the control TCP connection.

Parameters

  • message Message to send.

Returns

Number of bytes sent, or a negative value on error.


{#control}

control

net::TCPSocket & control()

Defined in src/turn/include/icy/turn/server/tcpallocation.h:75

Returns

Reference to the TCP control socket.


{#relayedaddress-2}

relayedAddress

virtual const nodiscard

[[nodiscard]] virtual net::Address relayedAddress() const

Defined in src/turn/include/icy/turn/server/tcpallocation.h:78

Returns

The listen address of the peer acceptor socket (used as the relayed address).

Reimplements

{#pairs}

pairs

TCPConnectionPairMap & pairs()

Defined in src/turn/include/icy/turn/server/tcpallocation.h:81

Returns

Reference to the map of active TCPConnectionPairs keyed by connection ID.


{#ontimer-5}

onTimer

bool onTimer()

Defined in src/turn/include/icy/turn/server/tcpallocation.h:86

Periodic timer callback; removes expired or pending-delete connection pairs, then calls the base class timer.

Returns

false if the allocation should be destroyed.


{#onpeeraccept}

onPeerAccept

void onPeerAccept(const net::TCPSocket::Ptr & sock)

Defined in src/turn/include/icy/turn/server/tcpallocation.h:91

Accepts incoming peer sockets on the relay acceptor socket. Checks permissions and sends a ConnectionAttempt indication to the control.

Parameters

  • sock Newly accepted peer socket.

{#oncontrolclosed}

onControlClosed

bool onControlClosed(net::Socket & socket)

Defined in src/turn/include/icy/turn/server/tcpallocation.h:96

Called when the control connection closes; marks the allocation for deletion.

Parameters

  • socket The closed control socket.

Returns

false (event propagation convention).

Protected Attributes

ReturnNameDescription
net::SocketEmitter_control
net::SocketEmitter_acceptor
TCPConnectionPairMap_pairs

{#_control}

_control

net::SocketEmitter _control

Defined in src/turn/include/icy/turn/server/tcpallocation.h:99


{#_acceptor}

_acceptor

net::SocketEmitter _acceptor

Defined in src/turn/include/icy/turn/server/tcpallocation.h:100


{#_pairs}

_pairs

TCPConnectionPairMap _pairs

Defined in src/turn/include/icy/turn/server/tcpallocation.h:101

{#tcpclient}

TCPClient

#include <icy/turn/client/tcpclient.h>
class TCPClient

Defined in src/turn/include/icy/turn/client/tcpclient.h:87

Inherits: Client

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.

List of all members

NameKindOwner
TCPClientfunctionDeclared here
startfunctionDeclared here
stopfunctionDeclared here
sendConnectRequestfunctionDeclared here
sendDatafunctionDeclared here
handleResponsefunctionDeclared here
handleConnectResponsefunctionDeclared here
handleConnectErrorResponsefunctionDeclared here
handleConnectionBindResponsefunctionDeclared here
handleConnectionBindErrorResponsefunctionDeclared here
handleConnectionAttemptIndicationfunctionDeclared here
createAndBindConnectionfunctionDeclared here
onRelayConnectionConnectfunctionDeclared here
onRelayDataReceivedfunctionDeclared here
onRelayConnectionErrorfunctionDeclared here
onRelayConnectionClosedfunctionDeclared here
freeConnectionfunctionDeclared here
transportProtocolfunctionDeclared here
connectionsfunctionDeclared here
classNamefunctionDeclared here
_observervariableDeclared here
_connectionsvariableDeclared here
ClientfunctionInherited from Client
startfunctionInherited from Client
stopfunctionInherited from Client
sendAllocatefunctionInherited from Client
addPermissionfunctionInherited from Client
addPermissionfunctionInherited from Client
sendCreatePermissionfunctionInherited from Client
sendChannelBindfunctionInherited from Client
sendRefreshfunctionInherited from Client
sendDatafunctionInherited from Client
handleResponsefunctionInherited from Client
handleAllocateResponsefunctionInherited from Client
handleAllocateErrorResponsefunctionInherited from Client
handleCreatePermissionResponsefunctionInherited from Client
handleCreatePermissionErrorResponsefunctionInherited from Client
handleRefreshResponsefunctionInherited from Client
handleDataIndicationfunctionInherited from Client
transportProtocolfunctionInherited from Client
createTransactionfunctionInherited from Client
authenticateRequestfunctionInherited from Client
sendAuthenticatedTransactionfunctionInherited from Client
removeTransactionfunctionInherited from Client
mappedAddressfunctionInherited from Client
relayedAddressfunctionInherited from Client
closedfunctionInherited from Client
observerfunctionInherited from Client
optionsfunctionInherited from Client
addPermissionfunctionInherited from Client
hasPermissionfunctionInherited from Client
hasPermissionfunctionInherited from Client
removePermissionfunctionInherited from Client
removePermissionfunctionInherited from Client
_observervariableInherited from Client
_optionsvariableInherited from Client
_socketvariableInherited from Client
_timervariableInherited from Client
_errorvariableInherited from Client
_mappedAddressvariableInherited from Client
_relayedAddressvariableInherited from Client
_realmvariableInherited from Client
_noncevariableInherited from Client
_pendingIndicationsvariableInherited from Client
_transactionsvariableInherited from Client
setErrorfunctionInherited from Client
onSocketConnectfunctionInherited from Client
onSocketRecvfunctionInherited from Client
onSocketClosefunctionInherited from Client
onTransactionProgressfunctionInherited from Client
onStateChangefunctionInherited from Client
onTimerfunctionInherited from Client
StateChangevariableInherited from Stateful
_statevariableInherited from Stateful
StatefulfunctionInherited from Stateful
~StatefulfunctionInherited from Stateful
stateEqualsfunctionInherited from Stateful
stateBetweenfunctionInherited from Stateful
statefunctionInherited from Stateful
statefunctionInherited from Stateful
beforeStateChangefunctionInherited from Stateful
onStateChangefunctionInherited from Stateful
setStatefunctionInherited from Stateful
setStatefunctionInherited from Stateful
operator<<friendInherited from IAllocation
IAllocationfunctionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
updateUsagefunctionInherited from IAllocation
setLifetimefunctionInherited from IAllocation
setBandwidthLimitfunctionInherited from IAllocation
expiredfunctionInherited from IAllocation
deletedfunctionInherited from IAllocation
bandwidthLimitfunctionInherited from IAllocation
bandwidthUsedfunctionInherited from IAllocation
bandwidthRemainingfunctionInherited from IAllocation
timeRemainingfunctionInherited from IAllocation
tuplefunctionInherited from IAllocation
usernamefunctionInherited from IAllocation
lifetimefunctionInherited from IAllocation
permissionsfunctionInherited from IAllocation
relayedAddressfunctionInherited from IAllocation
addPermissionfunctionInherited from IAllocation
addPermissionfunctionInherited from IAllocation
addPermissionsfunctionInherited from IAllocation
removePermissionfunctionInherited from IAllocation
removePermissionfunctionInherited from IAllocation
removeAllPermissionsfunctionInherited from IAllocation
removeExpiredPermissionsfunctionInherited from IAllocation
hasPermissionfunctionInherited from IAllocation
hasPermissionfunctionInherited from IAllocation
printfunctionInherited from IAllocation
_tuplevariableInherited from IAllocation
_usernamevariableInherited from IAllocation
_permissionsvariableInherited from IAllocation
_lifetimevariableInherited from IAllocation
_bandwidthLimitvariableInherited from IAllocation
_bandwidthUsedvariableInherited from IAllocation
_createdAtvariableInherited from IAllocation
_updatedAtvariableInherited from IAllocation
_deletedvariableInherited from IAllocation

Inherited from Client

KindNameDescription
functionClient
functionstart virtualConnects the socket to the TURN server and starts the allocation sequence. Permissions must be added via addPermission() before calling this.
functionstop virtualStops the timer, cancels pending transactions, and closes the socket.
functionsendAllocate virtualSends an Allocate request to the server with the configured transport and lifetime. On first call the server will typically respond with a 401 challenge; the client re-sends with credentials automatically.
functionaddPermission virtualAdds multiple peer IP addresses to the permission list.
functionaddPermission virtual overrideAdds a single peer IP to the permission list, or refreshes it if already present. Permissions should be added before start(); they may also be added later, in which case a new CreatePermission request is required.
functionsendCreatePermission virtualSends a CreatePermission request for all IPs currently in the permission list. Called automatically after allocation succeeds and periodically by the timer to refresh expiring permissions.
functionsendChannelBind virtualChannel bindings (RFC 5766 Section 11) are intentionally not implemented. They are a bandwidth optimization that replaces STUN-framed Send/Data indications with a compact 4-byte ChannelData header. This only benefits high-throughput media relay scenarios; in practice, media flows directly via ICE/DTLS rather than through this TURN client's data path, so the optimization is not worth the complexity (channel number allocation, 10-minute binding refresh timers, ChannelData wire framing). Data relay uses sendData() with Send Indications instead.
functionsendRefresh virtualSends a Refresh request to extend the allocation lifetime. Called automatically by the timer when roughly one-third of the lifetime remains.
functionsendData virtualSends a Send Indication to relay data to peerAddress through the TURN server. If permissions are still being negotiated the indication is queued and flushed once CreatePermission succeeds.
functionhandleResponse virtualDispatches an incoming STUN/TURN response to the appropriate handler.
functionhandleAllocateResponse virtualProcesses a successful Allocate response; extracts mapped/relayed addresses and advances the state to Authorizing, then sends CreatePermission.
functionhandleAllocateErrorResponse virtualHandles an Allocate error response; manages the 401 challenge/re-send flow and sets the client to Failed for unrecoverable errors.
functionhandleCreatePermissionResponse virtualHandles a successful CreatePermission response; flushes queued Send Indications and advances state to Success.
functionhandleCreatePermissionErrorResponse virtualHandles a failed CreatePermission response; clears all permissions and sets the client to Failed.
functionhandleRefreshResponse virtualHandles a Refresh response; updates the stored lifetime.
functionhandleDataIndication virtualHandles an incoming Data Indication; extracts peer address and data and forwards to ClientObserver::onRelayDataReceived().
functiontransportProtocol virtual
functioncreateTransaction virtualCreates a new STUN transaction, registers the progress callback, and adds it to the active transaction list.
functionauthenticateRequest virtualAdds STUN long-term credential attributes (Username, Realm, Nonce, MessageIntegrity) to request if the realm has been received from the server.
functionsendAuthenticatedTransaction virtualCalls authenticateRequest() then sends the transaction.
functionremoveTransaction virtualRemoves a transaction from the active list. The IntrusivePtr keeps the object alive until the caller's copy is released.
functionmappedAddress const nodiscard
functionrelayedAddress virtual const nodiscard override
functionclosed const nodiscard
functionobserver
functionoptions const nodiscard
functionaddPermission virtualAdds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
functionremovePermission virtualRemoves the permission for ip if present.
functionremovePermission virtualRemoves the permission for address if present. The port is ignored; TURN permissions are IP-only.
variable_observer
variable_options
variable_socket
variable_timer
variable_error
variable_mappedAddress
variable_relayedAddress
variable_realm
variable_nonce
variable_pendingIndicationsA list of queued Send indication packets awaiting server permissions.
variable_transactionsA list containing currently active transactions.
functionsetError virtualSets the error field and transitions the client to the Failed state.
functiononSocketConnect virtualSocket connect callback; starts the timer and sends the first Allocate request.
functiononSocketRecv virtualSocket receive callback; parses STUN messages from the buffer and dispatches them.
functiononSocketClose virtualSocket close callback; shuts down the client and records the socket error.
functiononTransactionProgress virtualSTUN transaction state-change callback; handles Success and Failed outcomes.
functiononStateChange overrideForwards state-change events to the observer.
functiononTimer virtualPeriodic timer callback; re-allocates on expiry or refreshes when lifetime is below one-third remaining. Also calls ClientObserver::onTimer().

Inherited from Stateful

KindNameDescription
variableStateChangeSignals when the state changes.
variable_state
functionStateful inline
function~Stateful virtual inline
functionstateEquals virtual const inlineReturns true if the current state ID equals the given ID.
functionstateBetween virtual const inlineReturns true if the current state ID is in the inclusive range [lid, rid].
functionstate virtual inlineReturns a mutable reference to the current state.
functionstate virtual const inlineReturns a copy of the current state.
functionbeforeStateChange virtual inlineOverride to handle pre state change logic. Return false to prevent state change.
functiononStateChange virtual inlineOverride to handle post state change logic.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.

Inherited from IAllocation

KindNameDescription
friendoperator<< inline
functionIAllocation
functionIAllocationDeleted constructor.
functionIAllocationDeleted constructor.
functionupdateUsage virtualUpdates the last-activity timestamp and accumulates bandwidth usage. Call this whenever data is relayed through the allocation.
functionsetLifetime virtualSets the allocation lifetime in seconds and resets the activity timestamp, effectively extending the expiry from the current moment.
functionsetBandwidthLimit virtualSets the maximum number of bytes this allocation may relay in its lifetime. Pass 0 to disable bandwidth limiting.
functionexpired virtual const nodiscard
functiondeleted virtual const nodiscardReturns true if the allocation's deleted flag is set and or if the allocation has expired.
functionbandwidthLimit virtual const nodiscard
functionbandwidthUsed virtual const nodiscard
functionbandwidthRemaining virtual const nodiscard
functiontimeRemaining virtual const nodiscard
functiontuple virtual
functionusername virtual const nodiscard
functionlifetime virtual const nodiscard
functionpermissions virtual const nodiscard
functionrelayedAddress virtual const nodiscard
functionaddPermission virtualAdds a permission for ip, or refreshes the existing one.
functionaddPermission virtualAdds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only.
functionaddPermissions virtualAdds (or refreshes) permissions for multiple IPs.
functionremovePermission virtualRemoves the permission for ip if present.
functionremovePermission virtualRemoves the permission for address if present. The port is ignored; TURN permissions are IP-only.
functionremoveAllPermissions virtualRemoves all permissions from the list.
functionremoveExpiredPermissions virtualRemoves any permissions whose 5-minute lifetime has elapsed.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
functionprint virtual const inline
variable_tuple
variable_username
variable_permissions
variable_lifetime
variable_bandwidthLimit
variable_bandwidthUsed
variable_createdAt
variable_updatedAt
variable_deleted

Public Methods

ReturnNameDescription
TCPClient
voidstart virtual overrideConnects the socket to the TURN server and starts the allocation sequence. Permissions must be added via addPermission() before calling this.
voidstop virtual overrideStops the control connection, cancels all relay connections, and calls the base class stop().
voidsendConnectRequest virtualSends a Connect request to the server asking it to open a TCP connection to peerAddress on the client's behalf (RFC 6062 section 4.3).
voidsendData virtual overrideSends raw data to peerAddress over the established relay connection. The peer must have an active permission and a bound relay connection.
boolhandleResponse virtual overrideExtends the base handler with Connect, ConnectionBind, and ConnectionAttempt responses.
voidhandleConnectResponse virtualProcesses a successful Connect response; extracts the connection ID and calls createAndBindConnection().
voidhandleConnectErrorResponse virtualProcesses a Connect error response; notifies the observer that binding failed.
voidhandleConnectionBindResponse virtualProcesses a successful ConnectionBind response; arms the relay socket for data transfer and notifies the observer.
voidhandleConnectionBindErrorResponse virtualProcesses a ConnectionBind error response; frees the failed connection.
voidhandleConnectionAttemptIndication virtualProcesses a ConnectionAttempt indication from the server; optionally accepts the incoming peer connection by calling createAndBindConnection().
boolcreateAndBindConnection virtualOpens a new TCP relay socket to the TURN server and sends a ConnectionBind request carrying connectionID.
boolonRelayConnectionConnect virtualRelay socket connect callback; sends the ConnectionBind request.
boolonRelayDataReceived virtualRelay socket receive callback; forwards data to the observer.
boolonRelayConnectionError virtualRelay socket error callback; notifies the observer of the error.
boolonRelayConnectionClosed virtualRelay socket close callback; notifies the observer and frees the connection.
voidfreeConnectionRemoves the relay connection for peerAddress, unregisters its callbacks, and deletes the associated RelayConnectionBinding.
inttransportProtocol virtual override
ConnectionManager &connections
const char *className virtual const inline

{#tcpclient-1}

TCPClient

TCPClient(TCPClientObserver & observer, const Client::Options & options = Client::Options())

Defined in src/turn/include/icy/turn/client/tcpclient.h:92

Parameters

  • observer Observer for TCP-specific relay events.

  • options Client configuration; defaults to loopback server, 5-min lifetime.


{#start-15}

start

virtual override

virtual void start() override

Defined in src/turn/include/icy/turn/client/tcpclient.h:96

Connects the socket to the TURN server and starts the allocation sequence. Permissions must be added via addPermission() before calling this.

Reimplements

{#stop-12}

stop

virtual override

virtual void stop() override

Defined in src/turn/include/icy/turn/client/tcpclient.h:100

Stops the control connection, cancels all relay connections, and calls the base class stop().

Reimplements

{#sendconnectrequest}

sendConnectRequest

virtual

virtual void sendConnectRequest(const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/client/tcpclient.h:105

Sends a Connect request to the server asking it to open a TCP connection to peerAddress on the client's behalf (RFC 6062 section 4.3).

Parameters

  • peerAddress Target peer address.

{#senddata-1}

sendData

virtual override

virtual void sendData(const char * data, size_t size, const net::Address & peerAddress) override

Defined in src/turn/include/icy/turn/client/tcpclient.h:112

Sends raw data to peerAddress over the established relay connection. The peer must have an active permission and a bound relay connection.

Parameters

  • data Payload bytes.

  • size Number of bytes to send.

  • peerAddress Destination peer (must have an entry in connections()).

Reimplements

{#handleresponse-1}

handleResponse

virtual override

virtual bool handleResponse(const stun::Message & response) override

Defined in src/turn/include/icy/turn/client/tcpclient.h:118

Extends the base handler with Connect, ConnectionBind, and ConnectionAttempt responses.

Parameters

  • response Incoming STUN response.

Returns

true if the message was handled.

Reimplements

{#handleconnectresponse}

handleConnectResponse

virtual

virtual void handleConnectResponse(const stun::Message & response)

Defined in src/turn/include/icy/turn/client/tcpclient.h:123

Processes a successful Connect response; extracts the connection ID and calls createAndBindConnection().

Parameters

  • response Connect success response.

{#handleconnecterrorresponse}

handleConnectErrorResponse

virtual

virtual void handleConnectErrorResponse(const stun::Message & response)

Defined in src/turn/include/icy/turn/client/tcpclient.h:127

Processes a Connect error response; notifies the observer that binding failed.

Parameters

  • response Connect error response.

{#handleconnectionbindresponse}

handleConnectionBindResponse

virtual

virtual void handleConnectionBindResponse(const stun::Message & response)

Defined in src/turn/include/icy/turn/client/tcpclient.h:132

Processes a successful ConnectionBind response; arms the relay socket for data transfer and notifies the observer.

Parameters

  • response ConnectionBind success response.

{#handleconnectionbinderrorresponse}

handleConnectionBindErrorResponse

virtual

virtual void handleConnectionBindErrorResponse(const stun::Message & response)

Defined in src/turn/include/icy/turn/client/tcpclient.h:136

Processes a ConnectionBind error response; frees the failed connection.

Parameters

  • response ConnectionBind error response.

{#handleconnectionattemptindication}

handleConnectionAttemptIndication

virtual

virtual void handleConnectionAttemptIndication(const stun::Message & response)

Defined in src/turn/include/icy/turn/client/tcpclient.h:141

Processes a ConnectionAttempt indication from the server; optionally accepts the incoming peer connection by calling createAndBindConnection().

Parameters

  • response ConnectionAttempt indication message.

{#createandbindconnection}

createAndBindConnection

virtual

virtual bool createAndBindConnection(uint32_t connectionID, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/client/tcpclient.h:148

Opens a new TCP relay socket to the TURN server and sends a ConnectionBind request carrying connectionID.

Parameters

  • connectionID TURN CONNECTION-ID from the server.

  • peerAddress Peer associated with this connection.

Returns

true on success.


{#onrelayconnectionconnect}

onRelayConnectionConnect

virtual

virtual bool onRelayConnectionConnect(net::Socket & socket)

Defined in src/turn/include/icy/turn/client/tcpclient.h:152

Relay socket connect callback; sends the ConnectionBind request.

Parameters

  • socket The relay socket that just connected.

{#onrelaydatareceived-1}

onRelayDataReceived

virtual

virtual bool onRelayDataReceived(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/client/tcpclient.h:158

Relay socket receive callback; forwards data to the observer.

Parameters

  • socket The receiving relay socket.

  • buffer Received data.

  • peerAddress Source address (populated by the socket layer).


{#onrelayconnectionerror}

onRelayConnectionError

virtual

virtual bool onRelayConnectionError(net::Socket & socket, const Error & error)

Defined in src/turn/include/icy/turn/client/tcpclient.h:163

Relay socket error callback; notifies the observer of the error.

Parameters

  • socket The affected relay socket.

  • error Error descriptor.


{#onrelayconnectionclosed}

onRelayConnectionClosed

virtual

virtual bool onRelayConnectionClosed(net::Socket & socket)

Defined in src/turn/include/icy/turn/client/tcpclient.h:167

Relay socket close callback; notifies the observer and frees the connection.

Parameters

  • socket The closed relay socket.

{#freeconnection}

freeConnection

void freeConnection(const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/client/tcpclient.h:172

Removes the relay connection for peerAddress, unregisters its callbacks, and deletes the associated RelayConnectionBinding.

Parameters

  • peerAddress Peer whose connection to release.

{#transportprotocol-1}

transportProtocol

virtual override

virtual int transportProtocol() override

Defined in src/turn/include/icy/turn/client/tcpclient.h:175

Returns

kProtocolTCP (6).

Reimplements

{#connections}

connections

ConnectionManager & connections()

Defined in src/turn/include/icy/turn/client/tcpclient.h:178

Returns

Reference to the map of active relay connections keyed by peer address.


{#classname-6}

className

virtual const inline

virtual inline const char * className() const

Defined in src/turn/include/icy/turn/client/tcpclient.h:180

Protected Attributes

ReturnNameDescription
TCPClientObserver &_observer
ConnectionManager_connections

{#_observer-3}

_observer

TCPClientObserver & _observer

Defined in src/turn/include/icy/turn/client/tcpclient.h:183


{#_connections-2}

_connections

ConnectionManager _connections

Defined in src/turn/include/icy/turn/client/tcpclient.h:184

{#tcpconnectionpair}

TCPConnectionPair

#include <icy/turn/server/tcpconnectionpair.h>
class TCPConnectionPair

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:35

Inherits: RefCounted< 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.

List of all members

NameKindOwner
allocationvariableDeclared here
clientvariableDeclared here
peervariableDeclared here
earlyPeerDatavariableDeclared here
connectionIDvariableDeclared here
isDataConnectionvariableDeclared here
pendingDeletevariableDeclared here
timeoutvariableDeclared here
transactionIDvariableDeclared here
TCPConnectionPairfunctionDeclared here
doPeerConnectfunctionDeclared here
makeDataConnectionfunctionDeclared here
setPeerSocketfunctionDeclared here
setClientSocketfunctionDeclared here
onPeerConnectSuccessfunctionDeclared here
onPeerConnectErrorfunctionDeclared here
onClientDataReceivedfunctionDeclared here
onPeerDataReceivedfunctionDeclared here
onConnectionClosedfunctionDeclared here
startTimeoutfunctionDeclared here
requestDeletionfunctionDeclared here
expiredfunctionDeclared here
PtrtypedefDeclared here
TCPConnectionPairfunctionDeclared here
TCPConnectionPairfunctionDeclared here
_refCountvariableInherited from RefCounted
RefCountedfunctionInherited from RefCounted
RefCountedfunctionInherited from RefCounted
operator=functionInherited from RefCounted
addReffunctionInherited from RefCounted
releaseReffunctionInherited from RefCounted
refCountfunctionInherited from RefCounted
~RefCountedfunctionInherited from RefCounted

Inherited from RefCounted

KindNameDescription
variable_refCount
functionRefCountedDefaulted constructor.
functionRefCounted inline noexcept
functionoperator= inline noexcept
functionaddRef const inline noexceptIncrements the reference count. Called by IntrusivePtr on acquisition.
functionreleaseRef const inline noexceptDecrements the reference count.
functionrefCount const inline nodiscard noexceptReturns the current reference count.
function~RefCountedDefaulted destructor.

Public Attributes

ReturnNameDescription
TCPAllocation &allocation
net::SocketEmitterclient
net::SocketEmitterpeer
BufferearlyPeerData
uint32_tconnectionID
boolisDataConnection
boolpendingDelete
Timeouttimeout
stun::TransactionIDtransactionID

{#allocation}

allocation

TCPAllocation & allocation

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:67


{#client-4}

client

net::SocketEmitter client

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:69


{#peer}

peer

net::SocketEmitter peer

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:70


{#earlypeerdata}

earlyPeerData

Buffer earlyPeerData

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:72


{#connectionid-1}

connectionID

uint32_t connectionID

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:73


{#isdataconnection}

isDataConnection

bool isDataConnection

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:74


{#pendingdelete}

pendingDelete

bool pendingDelete = false

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:75


{#timeout-3}

timeout

Timeout timeout

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:76


{#transactionid}

transactionID

stun::TransactionID transactionID

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:77

Public Methods

ReturnNameDescription
TCPConnectionPairConstructs a pair with a randomly assigned connection ID. The caller must add the pair to the allocation's pair map.
booldoPeerConnect
boolmakeDataConnection
voidsetPeerSocket
voidsetClientSocket
boolonPeerConnectSuccess
boolonPeerConnectError
boolonClientDataReceived
boolonPeerDataReceived
boolonConnectionClosed
voidstartTimeout
voidrequestDeletion
boolexpired const nodiscard

{#tcpconnectionpair-1}

TCPConnectionPair

TCPConnectionPair(TCPAllocation & allocation)

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:43

Constructs a pair with a randomly assigned connection ID. The caller must add the pair to the allocation's pair map.

Parameters


{#dopeerconnect}

doPeerConnect

bool doPeerConnect(const net::Address & peerAddr)

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:46


{#makedataconnection}

makeDataConnection

bool makeDataConnection()

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:47


{#setpeersocket}

setPeerSocket

void setPeerSocket(const net::TCPSocket::Ptr & socket)

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:49


{#setclientsocket}

setClientSocket

void setClientSocket(const net::TCPSocket::Ptr & socket)

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:50


{#onpeerconnectsuccess}

onPeerConnectSuccess

bool onPeerConnectSuccess(net::Socket & socket)

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:52


{#onpeerconnecterror}

onPeerConnectError

bool onPeerConnectError(net::Socket & socket, const Error & error)

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:53


{#onclientdatareceived}

onClientDataReceived

bool onClientDataReceived(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:55


{#onpeerdatareceived}

onPeerDataReceived

bool onPeerDataReceived(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:57


{#onconnectionclosed}

onConnectionClosed

bool onConnectionClosed(net::Socket & socket)

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:60


{#starttimeout}

startTimeout

void startTimeout()

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:62


{#requestdeletion}

requestDeletion

void requestDeletion()

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:63


{#expired-1}

expired

const nodiscard

[[nodiscard]] bool expired() const

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:65

Public Types

NameDescription
Ptr

{#ptr-15}

Ptr

using Ptr = IntrusivePtr< TCPConnectionPair >

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:38

Private Methods

ReturnNameDescription
TCPConnectionPairDeleted constructor.
TCPConnectionPairDeleted constructor.

{#tcpconnectionpair-2}

TCPConnectionPair

TCPConnectionPair(const TCPConnectionPair &) = delete

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:80

Deleted constructor.


{#tcpconnectionpair-3}

TCPConnectionPair

TCPConnectionPair(TCPConnectionPair &&) = delete

Defined in src/turn/include/icy/turn/server/tcpconnectionpair.h:82

Deleted constructor.

{#udpallocation}

UDPAllocation

#include <icy/turn/server/udpallocation.h>
class UDPAllocation

Defined in src/turn/include/icy/turn/server/udpallocation.h:31

Inherits: ServerAllocation

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.

List of all members

NameKindOwner
UDPAllocationfunctionDeclared here
onPeerDataReceivedfunctionDeclared here
handleRequestfunctionDeclared here
handleSendIndicationfunctionDeclared here
sendfunctionDeclared here
relayedAddressfunctionDeclared here
_relaySocketvariableDeclared here
ServerfriendInherited from ServerAllocation
ServerAllocationfunctionInherited from ServerAllocation
handleRequestfunctionInherited from ServerAllocation
handleRefreshRequestfunctionInherited from ServerAllocation
handleCreatePermissionfunctionInherited from ServerAllocation
onTimerfunctionInherited from ServerAllocation
timeRemainingfunctionInherited from ServerAllocation
maxTimeRemainingfunctionInherited from ServerAllocation
hasPermissionfunctionInherited from ServerAllocation
hasPermissionfunctionInherited from ServerAllocation
serverfunctionInherited from ServerAllocation
printfunctionInherited from ServerAllocation
refreshDeleteRequestedfunctionInherited from ServerAllocation
_maxLifetimevariableInherited from ServerAllocation
_servervariableInherited from ServerAllocation
_permissionPolicyvariableInherited from ServerAllocation
_refreshDeleteRequestedvariableInherited from ServerAllocation
ServerAllocationfunctionInherited from ServerAllocation
ServerAllocationfunctionInherited from ServerAllocation
operator<<friendInherited from IAllocation
IAllocationfunctionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
updateUsagefunctionInherited from IAllocation
setLifetimefunctionInherited from IAllocation
setBandwidthLimitfunctionInherited from IAllocation
expiredfunctionInherited from IAllocation
deletedfunctionInherited from IAllocation
bandwidthLimitfunctionInherited from IAllocation
bandwidthUsedfunctionInherited from IAllocation
bandwidthRemainingfunctionInherited from IAllocation
timeRemainingfunctionInherited from IAllocation
tuplefunctionInherited from IAllocation
usernamefunctionInherited from IAllocation
lifetimefunctionInherited from IAllocation
permissionsfunctionInherited from IAllocation
relayedAddressfunctionInherited from IAllocation
addPermissionfunctionInherited from IAllocation
addPermissionfunctionInherited from IAllocation
addPermissionsfunctionInherited from IAllocation
removePermissionfunctionInherited from IAllocation
removePermissionfunctionInherited from IAllocation
removeAllPermissionsfunctionInherited from IAllocation
removeExpiredPermissionsfunctionInherited from IAllocation
hasPermissionfunctionInherited from IAllocation
hasPermissionfunctionInherited from IAllocation
printfunctionInherited from IAllocation
_tuplevariableInherited from IAllocation
_usernamevariableInherited from IAllocation
_permissionsvariableInherited from IAllocation
_lifetimevariableInherited from IAllocation
_bandwidthLimitvariableInherited from IAllocation
_bandwidthUsedvariableInherited from IAllocation
_createdAtvariableInherited from IAllocation
_updatedAtvariableInherited from IAllocation
_deletedvariableInherited from IAllocation

Inherited from ServerAllocation

KindNameDescription
friendServer
functionServerAllocation
functionhandleRequest virtualDispatches incoming STUN requests to handleCreatePermission() or handleRefreshRequest(). Subclasses override to add transport-specific methods.
functionhandleRefreshRequest virtualProcesses a Refresh request; updates the lifetime or sets the delete flag if the requested lifetime is 0, then sends a success response.
functionhandleCreatePermission virtualProcesses a CreatePermission request; installs or refreshes permissions for each XOR-PEER-ADDRESS attribute, then sends a success response.
functiononTimer nodiscardPeriodic maintenance callback called by Server::onTimer(). Removes expired permissions. Returns false to signal that this allocation should be destroyed.
functiontimeRemaining virtual const nodiscard override
functionmaxTimeRemaining const nodiscard
functionhasPermission virtual nodiscard overrideChecks permission, auto-granting local IPs if enabled in server options.
functionhasPermission virtual nodiscard overrideChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
functionserver virtual
functionprint virtual const overrideWrites a detailed diagnostic dump of this allocation to os.
functionrefreshDeleteRequested const inline nodiscardReturns true if the refresh request set lifetime to 0, signaling the parent Server to delete this allocation.
variable_maxLifetime
variable_server
variable_permissionPolicy
variable_refreshDeleteRequested
functionServerAllocationNonCopyable and NonMovable.
functionServerAllocationDeleted constructor.

Inherited from IAllocation

KindNameDescription
friendoperator<< inline
functionIAllocation
functionIAllocationDeleted constructor.
functionIAllocationDeleted constructor.
functionupdateUsage virtualUpdates the last-activity timestamp and accumulates bandwidth usage. Call this whenever data is relayed through the allocation.
functionsetLifetime virtualSets the allocation lifetime in seconds and resets the activity timestamp, effectively extending the expiry from the current moment.
functionsetBandwidthLimit virtualSets the maximum number of bytes this allocation may relay in its lifetime. Pass 0 to disable bandwidth limiting.
functionexpired virtual const nodiscard
functiondeleted virtual const nodiscardReturns true if the allocation's deleted flag is set and or if the allocation has expired.
functionbandwidthLimit virtual const nodiscard
functionbandwidthUsed virtual const nodiscard
functionbandwidthRemaining virtual const nodiscard
functiontimeRemaining virtual const nodiscard
functiontuple virtual
functionusername virtual const nodiscard
functionlifetime virtual const nodiscard
functionpermissions virtual const nodiscard
functionrelayedAddress virtual const nodiscard
functionaddPermission virtualAdds a permission for ip, or refreshes the existing one.
functionaddPermission virtualAdds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only.
functionaddPermissions virtualAdds (or refreshes) permissions for multiple IPs.
functionremovePermission virtualRemoves the permission for ip if present.
functionremovePermission virtualRemoves the permission for address if present. The port is ignored; TURN permissions are IP-only.
functionremoveAllPermissions virtualRemoves all permissions from the list.
functionremoveExpiredPermissions virtualRemoves any permissions whose 5-minute lifetime has elapsed.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
functionprint virtual const inline
variable_tuple
variable_username
variable_permissions
variable_lifetime
variable_bandwidthLimit
variable_bandwidthUsed
variable_createdAt
variable_updatedAt
variable_deleted

Public Methods

ReturnNameDescription
UDPAllocationBinds the relay UDP socket and registers the peer receive callback.
boolonPeerDataReceivedReceive callback for the relay UDP socket; validates permissions, updates bandwidth usage, and forwards data to the client as a Data Indication.
boolhandleRequest virtualExtends the base handler with Send Indication support.
voidhandleSendIndicationHandles a Send Indication from the client; validates permissions and relays the DATA attribute payload to the peer via the relay socket. Silently discards on permission or attribute errors.
ssize_tsendSends raw data to peerAddress via the relay UDP socket. Updates bandwidth usage and returns -1 if the allocation is expired.
net::AddressrelayedAddress virtual const nodiscard

{#udpallocation-1}

UDPAllocation

UDPAllocation(Server & server, const FiveTuple & tuple, const std::string & username, const uint32_t & lifetime)

Defined in src/turn/include/icy/turn/server/udpallocation.h:39

Binds the relay UDP socket and registers the peer receive callback.

Parameters

  • server Owning TURN server.

  • tuple 5-tuple identifying this allocation.

  • username Authenticated username from the Allocate request.

  • lifetime Initial lifetime in seconds.


{#onpeerdatareceived-1}

onPeerDataReceived

bool onPeerDataReceived(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/server/udpallocation.h:48

Receive callback for the relay UDP socket; validates permissions, updates bandwidth usage, and forwards data to the client as a Data Indication.

Parameters

  • socket The relay socket.

  • buffer Received datagram.

  • peerAddress Source address of the peer datagram.


{#handlerequest-3}

handleRequest

virtual

virtual bool handleRequest(Request & request)

Defined in src/turn/include/icy/turn/server/udpallocation.h:54

Extends the base handler with Send Indication support.

Parameters

  • request Incoming STUN request or indication.

Returns

true if handled.

Reimplements

{#handlesendindication}

handleSendIndication

void handleSendIndication(Request & request)

Defined in src/turn/include/icy/turn/server/udpallocation.h:60

Handles a Send Indication from the client; validates permissions and relays the DATA attribute payload to the peer via the relay socket. Silently discards on permission or attribute errors.

Parameters

  • request Incoming Send Indication.

{#send-16}

send

ssize_t send(const char * data, size_t size, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/server/udpallocation.h:68

Sends raw data to peerAddress via the relay UDP socket. Updates bandwidth usage and returns -1 if the allocation is expired.

Parameters

  • data Payload bytes to relay.

  • size Number of bytes.

  • peerAddress Destination peer address.

Returns

Number of bytes sent, or -1 if the quota is exhausted.


{#relayedaddress-3}

relayedAddress

virtual const nodiscard

[[nodiscard]] virtual net::Address relayedAddress() const

Defined in src/turn/include/icy/turn/server/udpallocation.h:72

Returns

The bound address of the relay UDP socket.

Reimplements

Private Attributes

ReturnNameDescription
net::SocketEmitter_relaySocket

{#_relaysocket}

_relaySocket

net::SocketEmitter _relaySocket

Defined in src/turn/include/icy/turn/server/udpallocation.h:75

{#udpclient}

UDPClient

#include <icy/turn/client/udpclient.h>
class UDPClient

Defined in src/turn/include/icy/turn/client/udpclient.h:31

Inherits: Client

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.

List of all members

NameKindOwner
UDPClientfunctionDeclared here
ClientfunctionInherited from Client
startfunctionInherited from Client
stopfunctionInherited from Client
sendAllocatefunctionInherited from Client
addPermissionfunctionInherited from Client
addPermissionfunctionInherited from Client
sendCreatePermissionfunctionInherited from Client
sendChannelBindfunctionInherited from Client
sendRefreshfunctionInherited from Client
sendDatafunctionInherited from Client
handleResponsefunctionInherited from Client
handleAllocateResponsefunctionInherited from Client
handleAllocateErrorResponsefunctionInherited from Client
handleCreatePermissionResponsefunctionInherited from Client
handleCreatePermissionErrorResponsefunctionInherited from Client
handleRefreshResponsefunctionInherited from Client
handleDataIndicationfunctionInherited from Client
transportProtocolfunctionInherited from Client
createTransactionfunctionInherited from Client
authenticateRequestfunctionInherited from Client
sendAuthenticatedTransactionfunctionInherited from Client
removeTransactionfunctionInherited from Client
mappedAddressfunctionInherited from Client
relayedAddressfunctionInherited from Client
closedfunctionInherited from Client
observerfunctionInherited from Client
optionsfunctionInherited from Client
addPermissionfunctionInherited from Client
hasPermissionfunctionInherited from Client
hasPermissionfunctionInherited from Client
removePermissionfunctionInherited from Client
removePermissionfunctionInherited from Client
_observervariableInherited from Client
_optionsvariableInherited from Client
_socketvariableInherited from Client
_timervariableInherited from Client
_errorvariableInherited from Client
_mappedAddressvariableInherited from Client
_relayedAddressvariableInherited from Client
_realmvariableInherited from Client
_noncevariableInherited from Client
_pendingIndicationsvariableInherited from Client
_transactionsvariableInherited from Client
setErrorfunctionInherited from Client
onSocketConnectfunctionInherited from Client
onSocketRecvfunctionInherited from Client
onSocketClosefunctionInherited from Client
onTransactionProgressfunctionInherited from Client
onStateChangefunctionInherited from Client
onTimerfunctionInherited from Client
StateChangevariableInherited from Stateful
_statevariableInherited from Stateful
StatefulfunctionInherited from Stateful
~StatefulfunctionInherited from Stateful
stateEqualsfunctionInherited from Stateful
stateBetweenfunctionInherited from Stateful
statefunctionInherited from Stateful
statefunctionInherited from Stateful
beforeStateChangefunctionInherited from Stateful
onStateChangefunctionInherited from Stateful
setStatefunctionInherited from Stateful
setStatefunctionInherited from Stateful
operator<<friendInherited from IAllocation
IAllocationfunctionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
updateUsagefunctionInherited from IAllocation
setLifetimefunctionInherited from IAllocation
setBandwidthLimitfunctionInherited from IAllocation
expiredfunctionInherited from IAllocation
deletedfunctionInherited from IAllocation
bandwidthLimitfunctionInherited from IAllocation
bandwidthUsedfunctionInherited from IAllocation
bandwidthRemainingfunctionInherited from IAllocation
timeRemainingfunctionInherited from IAllocation
tuplefunctionInherited from IAllocation
usernamefunctionInherited from IAllocation
lifetimefunctionInherited from IAllocation
permissionsfunctionInherited from IAllocation
relayedAddressfunctionInherited from IAllocation
addPermissionfunctionInherited from IAllocation
addPermissionfunctionInherited from IAllocation
addPermissionsfunctionInherited from IAllocation
removePermissionfunctionInherited from IAllocation
removePermissionfunctionInherited from IAllocation
removeAllPermissionsfunctionInherited from IAllocation
removeExpiredPermissionsfunctionInherited from IAllocation
hasPermissionfunctionInherited from IAllocation
hasPermissionfunctionInherited from IAllocation
printfunctionInherited from IAllocation
_tuplevariableInherited from IAllocation
_usernamevariableInherited from IAllocation
_permissionsvariableInherited from IAllocation
_lifetimevariableInherited from IAllocation
_bandwidthLimitvariableInherited from IAllocation
_bandwidthUsedvariableInherited from IAllocation
_createdAtvariableInherited from IAllocation
_updatedAtvariableInherited from IAllocation
_deletedvariableInherited from IAllocation

Inherited from Client

KindNameDescription
functionClient
functionstart virtualConnects the socket to the TURN server and starts the allocation sequence. Permissions must be added via addPermission() before calling this.
functionstop virtualStops the timer, cancels pending transactions, and closes the socket.
functionsendAllocate virtualSends an Allocate request to the server with the configured transport and lifetime. On first call the server will typically respond with a 401 challenge; the client re-sends with credentials automatically.
functionaddPermission virtualAdds multiple peer IP addresses to the permission list.
functionaddPermission virtual overrideAdds a single peer IP to the permission list, or refreshes it if already present. Permissions should be added before start(); they may also be added later, in which case a new CreatePermission request is required.
functionsendCreatePermission virtualSends a CreatePermission request for all IPs currently in the permission list. Called automatically after allocation succeeds and periodically by the timer to refresh expiring permissions.
functionsendChannelBind virtualChannel bindings (RFC 5766 Section 11) are intentionally not implemented. They are a bandwidth optimization that replaces STUN-framed Send/Data indications with a compact 4-byte ChannelData header. This only benefits high-throughput media relay scenarios; in practice, media flows directly via ICE/DTLS rather than through this TURN client's data path, so the optimization is not worth the complexity (channel number allocation, 10-minute binding refresh timers, ChannelData wire framing). Data relay uses sendData() with Send Indications instead.
functionsendRefresh virtualSends a Refresh request to extend the allocation lifetime. Called automatically by the timer when roughly one-third of the lifetime remains.
functionsendData virtualSends a Send Indication to relay data to peerAddress through the TURN server. If permissions are still being negotiated the indication is queued and flushed once CreatePermission succeeds.
functionhandleResponse virtualDispatches an incoming STUN/TURN response to the appropriate handler.
functionhandleAllocateResponse virtualProcesses a successful Allocate response; extracts mapped/relayed addresses and advances the state to Authorizing, then sends CreatePermission.
functionhandleAllocateErrorResponse virtualHandles an Allocate error response; manages the 401 challenge/re-send flow and sets the client to Failed for unrecoverable errors.
functionhandleCreatePermissionResponse virtualHandles a successful CreatePermission response; flushes queued Send Indications and advances state to Success.
functionhandleCreatePermissionErrorResponse virtualHandles a failed CreatePermission response; clears all permissions and sets the client to Failed.
functionhandleRefreshResponse virtualHandles a Refresh response; updates the stored lifetime.
functionhandleDataIndication virtualHandles an incoming Data Indication; extracts peer address and data and forwards to ClientObserver::onRelayDataReceived().
functiontransportProtocol virtual
functioncreateTransaction virtualCreates a new STUN transaction, registers the progress callback, and adds it to the active transaction list.
functionauthenticateRequest virtualAdds STUN long-term credential attributes (Username, Realm, Nonce, MessageIntegrity) to request if the realm has been received from the server.
functionsendAuthenticatedTransaction virtualCalls authenticateRequest() then sends the transaction.
functionremoveTransaction virtualRemoves a transaction from the active list. The IntrusivePtr keeps the object alive until the caller's copy is released.
functionmappedAddress const nodiscard
functionrelayedAddress virtual const nodiscard override
functionclosed const nodiscard
functionobserver
functionoptions const nodiscard
functionaddPermission virtualAdds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
functionremovePermission virtualRemoves the permission for ip if present.
functionremovePermission virtualRemoves the permission for address if present. The port is ignored; TURN permissions are IP-only.
variable_observer
variable_options
variable_socket
variable_timer
variable_error
variable_mappedAddress
variable_relayedAddress
variable_realm
variable_nonce
variable_pendingIndicationsA list of queued Send indication packets awaiting server permissions.
variable_transactionsA list containing currently active transactions.
functionsetError virtualSets the error field and transitions the client to the Failed state.
functiononSocketConnect virtualSocket connect callback; starts the timer and sends the first Allocate request.
functiononSocketRecv virtualSocket receive callback; parses STUN messages from the buffer and dispatches them.
functiononSocketClose virtualSocket close callback; shuts down the client and records the socket error.
functiononTransactionProgress virtualSTUN transaction state-change callback; handles Success and Failed outcomes.
functiononStateChange overrideForwards state-change events to the observer.
functiononTimer virtualPeriodic timer callback; re-allocates on expiry or refreshes when lifetime is below one-third remaining. Also calls ClientObserver::onTimer().

Inherited from Stateful

KindNameDescription
variableStateChangeSignals when the state changes.
variable_state
functionStateful inline
function~Stateful virtual inline
functionstateEquals virtual const inlineReturns true if the current state ID equals the given ID.
functionstateBetween virtual const inlineReturns true if the current state ID is in the inclusive range [lid, rid].
functionstate virtual inlineReturns a mutable reference to the current state.
functionstate virtual const inlineReturns a copy of the current state.
functionbeforeStateChange virtual inlineOverride to handle pre state change logic. Return false to prevent state change.
functiononStateChange virtual inlineOverride to handle post state change logic.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.

Inherited from IAllocation

KindNameDescription
friendoperator<< inline
functionIAllocation
functionIAllocationDeleted constructor.
functionIAllocationDeleted constructor.
functionupdateUsage virtualUpdates the last-activity timestamp and accumulates bandwidth usage. Call this whenever data is relayed through the allocation.
functionsetLifetime virtualSets the allocation lifetime in seconds and resets the activity timestamp, effectively extending the expiry from the current moment.
functionsetBandwidthLimit virtualSets the maximum number of bytes this allocation may relay in its lifetime. Pass 0 to disable bandwidth limiting.
functionexpired virtual const nodiscard
functiondeleted virtual const nodiscardReturns true if the allocation's deleted flag is set and or if the allocation has expired.
functionbandwidthLimit virtual const nodiscard
functionbandwidthUsed virtual const nodiscard
functionbandwidthRemaining virtual const nodiscard
functiontimeRemaining virtual const nodiscard
functiontuple virtual
functionusername virtual const nodiscard
functionlifetime virtual const nodiscard
functionpermissions virtual const nodiscard
functionrelayedAddress virtual const nodiscard
functionaddPermission virtualAdds a permission for ip, or refreshes the existing one.
functionaddPermission virtualAdds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only.
functionaddPermissions virtualAdds (or refreshes) permissions for multiple IPs.
functionremovePermission virtualRemoves the permission for ip if present.
functionremovePermission virtualRemoves the permission for address if present. The port is ignored; TURN permissions are IP-only.
functionremoveAllPermissions virtualRemoves all permissions from the list.
functionremoveExpiredPermissions virtualRemoves any permissions whose 5-minute lifetime has elapsed.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted.
functionhasPermission virtual nodiscardChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
functionprint virtual const inline
variable_tuple
variable_username
variable_permissions
variable_lifetime
variable_bandwidthLimit
variable_bandwidthUsed
variable_createdAt
variable_updatedAt
variable_deleted

Public Methods

ReturnNameDescription
UDPClient

{#udpclient-1}

UDPClient

UDPClient(ClientObserver & observer, const Options & options = Options())

Defined in src/turn/include/icy/turn/client/udpclient.h:36

Parameters

  • observer Observer for allocation lifecycle and data relay events.

  • options Client configuration; defaults to loopback server, 5-min lifetime.

{#clientobserver}

ClientObserver

#include <icy/turn/client/client.h>
struct ClientObserver

Defined in src/turn/include/icy/turn/client/client.h:69

Subclassed by: TCPClientObserver

Abstract observer interface for TURN client events. Callers subclass this to receive allocation lifecycle and data relay callbacks.

List of all members

NameKindOwner
onClientStateChangefunctionDeclared here
onRelayDataReceivedfunctionDeclared here
onAllocationFailedfunctionDeclared here
onAllocationDeletedfunctionDeclared here
onAllocationPermissionsCreatedfunctionDeclared here
onTransactionResponsefunctionDeclared here
onTimerfunctionDeclared here

Public Methods

ReturnNameDescription
voidonClientStateChange virtualCalled whenever the client's state machine transitions to a new state.
voidonRelayDataReceived virtualCalled when relayed data is received from a peer via a Data Indication.
voidonAllocationFailed virtual inlineCalled when the server rejects an Allocate request with an error.
voidonAllocationDeleted virtual inlineCalled when the server confirms deletion of the allocation.
voidonAllocationPermissionsCreated virtual inlineCalled after a CreatePermission request succeeds.
voidonTransactionResponse virtual inlineAll received transaction responses will be routed here after local processing so the observer can easily implement extra functionality.
voidonTimer virtual inlineFires after the client's internal timer callback. Handy for performing extra async cleanup tasks.

{#onclientstatechange}

onClientStateChange

virtual

virtual void onClientStateChange(Client & client, ClientState & state, const ClientState & oldState)

Defined in src/turn/include/icy/turn/client/client.h:75

Called whenever the client's state machine transitions to a new state.

Parameters

  • client The client that changed state.

  • state The new state.

  • oldState The previous state.


{#onrelaydatareceived}

onRelayDataReceived

virtual

virtual void onRelayDataReceived(Client & client, const char * data, size_t size, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/client/client.h:82

Called when relayed data is received from a peer via a Data Indication.

Parameters

  • client The owning client.

  • data Pointer to the received payload bytes.

  • size Number of bytes in data.

  • peerAddress Source address of the remote peer.


{#onallocationfailed}

onAllocationFailed

virtual inline

virtual inline void onAllocationFailed(Client & client, int errorCode, const std::string & reason)

Defined in src/turn/include/icy/turn/client/client.h:88

Called when the server rejects an Allocate request with an error.

Parameters

  • client The owning client.

  • errorCode STUN error code (e.g. 401, 438).

  • reason Human-readable error reason string.


{#onallocationdeleted}

onAllocationDeleted

virtual inline

virtual inline void onAllocationDeleted(Client & client, const stun::Transaction & transaction)

Defined in src/turn/include/icy/turn/client/client.h:93

Called when the server confirms deletion of the allocation.

Parameters

  • client The owning client.

  • transaction The completed Refresh transaction (lifetime == 0).


{#onallocationpermissionscreated}

onAllocationPermissionsCreated

virtual inline

virtual inline void onAllocationPermissionsCreated(Client & client, const PermissionList & permissions)

Defined in src/turn/include/icy/turn/client/client.h:98

Called after a CreatePermission request succeeds.

Parameters

  • client The owning client.

  • permissions The full list of active permissions after this update.


{#ontransactionresponse}

onTransactionResponse

virtual inline

virtual inline void onTransactionResponse(Client & client, const stun::Transaction & transaction)

Defined in src/turn/include/icy/turn/client/client.h:104

All received transaction responses will be routed here after local processing so the observer can easily implement extra functionality.

Parameters

  • client The owning client.

  • transaction The completed transaction (request + response accessible).


{#ontimer-2}

onTimer

virtual inline

virtual inline void onTimer(Client & client)

Defined in src/turn/include/icy/turn/client/client.h:109

Fires after the client's internal timer callback. Handy for performing extra async cleanup tasks.

Parameters

  • client The owning client.

{#clientstate}

ClientState

#include <icy/turn/client/client.h>
struct ClientState

Defined in src/turn/include/icy/turn/client/client.h:30

Inherits: State

State machine states for the TURN client.

List of all members

NameKindOwner
toStringfunctionDeclared here
TypeenumDeclared here
IDtypedefInherited from State
_idvariableInherited from State
StatefunctionInherited from State
StatefunctionInherited from State
operator=functionInherited from State
~StatefunctionInherited from State
idfunctionInherited from State
setfunctionInherited from State
strfunctionInherited from State
toStringfunctionInherited from State
equalsfunctionInherited from State
betweenfunctionInherited from State
operator==functionInherited from State
operator==functionInherited from State
operator<<friendInherited from State

Inherited from State

KindNameDescription
typedefID
variable_id
functionState
functionStateCopy constructor.
functionoperator=Copy assignment.
function~State virtualDefaulted destructor.
functionid constReturns the current state ID.
functionsetSets the state ID.
functionstr virtual constReturns a human-readable string for the given state ID. Override in derived classes to provide meaningful names.
functiontoString virtual constReturns a human-readable string for the current state ID.
functionequals constReturns true if the current state ID equals the given ID.
functionbetween constReturns true if the current state ID is in the inclusive range [lid, rid].
functionoperator== const inline
functionoperator== const inline
friendoperator<< inline

Public Methods

ReturnNameDescription
std::stringtoString virtual const inline

{#tostring-6}

toString

virtual const inline

virtual inline std::string toString() const

Defined in src/turn/include/icy/turn/client/client.h:43

Returns

Human-readable name for the current state.

Reimplements

Public Types

NameDescription
Type

{#type-13}

Type

enum Type

Defined in src/turn/include/icy/turn/client/client.h:32

ValueDescription
None
Allocating
Authorizing
Success
Failed

{#permission}

Permission

#include <icy/turn/permission.h>
struct Permission

Defined in src/turn/include/icy/turn/permission.h:37

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.

List of all members

NameKindOwner
ipvariableDeclared here
keyvariableDeclared here
timeoutvariableDeclared here
PermissionfunctionDeclared here
PermissionfunctionDeclared here
refreshfunctionDeclared here
operator==functionDeclared here
matchesfunctionDeclared here

Public Attributes

ReturnNameDescription
std::stringipIPv4 address string of the permitted peer.
KeykeyBinary IP key for allocation hot-path comparisons.
TimeouttimeoutCountdown timer; expires after PERMISSION_LIFETIME milliseconds.

{#ip}

ip

std::string ip

Defined in src/turn/include/icy/turn/permission.h:100

IPv4 address string of the permitted peer.


{#key}

key

Key key

Defined in src/turn/include/icy/turn/permission.h:101

Binary IP key for allocation hot-path comparisons.


{#timeout-2}

timeout

Timeout timeout

Defined in src/turn/include/icy/turn/permission.h:102

Countdown timer; expires after PERMISSION_LIFETIME milliseconds.

Public Methods

ReturnNameDescription
Permission inlineConstructs a permission for ip and immediately starts the expiry timer.
Permission inlineConstructs a permission from a binary socket address.
voidrefresh inlineResets the expiry timer, extending the permission lifetime by another 300 seconds.
booloperator== const inlineEquality comparison against an IP string.
boolmatches const inline nodiscardBinary IP comparison used on the TURN relay hot path.

{#permission-1}

Permission

inline

inline Permission(const std::string & ip)

Defined in src/turn/include/icy/turn/permission.h:106

Constructs a permission for ip and immediately starts the expiry timer.

Parameters

  • ip IPv4 address string of the permitted peer.

{#permission-2}

Permission

inline

inline Permission(const net::Address & address)

Defined in src/turn/include/icy/turn/permission.h:116

Constructs a permission from a binary socket address.

Parameters

  • address Peer IP address; port is ignored.

{#refresh}

refresh

inline

inline void refresh()

Defined in src/turn/include/icy/turn/permission.h:125

Resets the expiry timer, extending the permission lifetime by another 300 seconds.


{#operator-29}

operator==

const inline

inline bool operator==(std::string_view r) const

Defined in src/turn/include/icy/turn/permission.h:130

Equality comparison against an IP string.

Parameters

  • r IPv4 address string to compare against.

Returns

true if this permission's IP matches r.


{#matches}

matches

const inline nodiscard

[[nodiscard]] inline bool matches(const net::Address & address) const

Defined in src/turn/include/icy/turn/permission.h:133

Binary IP comparison used on the TURN relay hot path.

{#key-1}

Key

#include <icy/turn/permission.h>
struct Key

Defined in src/turn/include/icy/turn/permission.h:39

List of all members

NameKindOwner
afvariableDeclared here
bytesvariableDeclared here
sizevariableDeclared here
validfunctionDeclared here
matchesfunctionDeclared here
matchesfunctionDeclared here
fromAddressfunctionDeclared here
fromIPfunctionDeclared here

Public Attributes

ReturnNameDescription
intaf
std::array< uint8_t, 16 >bytes
uint8_tsize

{#af-1}

af

int af = AF_UNSPEC

Defined in src/turn/include/icy/turn/permission.h:41


{#bytes}

bytes

std::array< uint8_t, 16 > bytes {}

Defined in src/turn/include/icy/turn/permission.h:42


{#size-3}

size

uint8_t size = 0

Defined in src/turn/include/icy/turn/permission.h:43

Public Methods

ReturnNameDescription
boolvalid const inline nodiscard
boolmatches const inline nodiscard
boolmatches const inline nodiscard

{#valid-8}

valid

const inline nodiscard

[[nodiscard]] inline bool valid() const

Defined in src/turn/include/icy/turn/permission.h:45


{#matches-1}

matches

const inline nodiscard

[[nodiscard]] inline bool matches(const net::Address & address) const

Defined in src/turn/include/icy/turn/permission.h:81


{#matches-2}

matches

const inline nodiscard

[[nodiscard]] inline bool matches(const Key & other) const

Defined in src/turn/include/icy/turn/permission.h:90

Public Static Methods

ReturnNameDescription
KeyfromAddress static inline
KeyfromIP static inline

{#fromaddress}

fromAddress

static inline

static inline Key fromAddress(const net::Address & address)

Defined in src/turn/include/icy/turn/permission.h:50


{#fromip}

fromIP

static inline

static inline Key fromIP(const std::string & ip)

Defined in src/turn/include/icy/turn/permission.h:72

{#relayconnectionbinding}

RelayConnectionBinding

#include <icy/turn/client/tcpclient.h>
struct RelayConnectionBinding

Defined in src/turn/include/icy/turn/client/tcpclient.h:70

Binding metadata stored as socket opaque data during a ConnectionBind handshake. Associates a relay socket with its TURN connection ID and peer address.

List of all members

NameKindOwner
connectionIDvariableDeclared here
peerAddressvariableDeclared here

Public Attributes

ReturnNameDescription
uint32_tconnectionIDTURN CONNECTION-ID attribute value from the server.
net::AddresspeerAddressThe peer address this binding targets.

{#connectionid}

connectionID

uint32_t connectionID

Defined in src/turn/include/icy/turn/client/tcpclient.h:72

TURN CONNECTION-ID attribute value from the server.


{#peeraddress-5}

peerAddress

net::Address peerAddress

Defined in src/turn/include/icy/turn/client/tcpclient.h:73

The peer address this binding targets.

{#serverobserver}

ServerObserver

#include <icy/turn/server/server.h>
struct ServerObserver

Defined in src/turn/include/icy/turn/server/server.h:96

Observer interface that the application must implement to participate in server-side allocation management and authentication.

The observer is responsible for enforcing per-user allocation quotas and bandwidth limits. Implementations may perform authentication synchronously (returning Authorized/NotAuthorized immediately) or asynchronously (returning Authenticating and calling handleRequest() again later).

List of all members

NameKindOwner
onServerAllocationCreatedfunctionDeclared here
onServerAllocationRemovedfunctionDeclared here
authenticateRequestfunctionDeclared here

Public Methods

ReturnNameDescription
voidonServerAllocationCreated virtualCalled after a new allocation is successfully created.
voidonServerAllocationRemoved virtualCalled just before an allocation is destroyed (expired, deleted, or server stopped).
AuthenticationStateauthenticateRequest virtualAuthenticates an incoming STUN request using the long-term credential mechanism (RFC 5389 section 10.2). Return Authorized to proceed, NotAuthorized to reject with a 401, QuotaReached to reject with a 486, or Authenticating to defer until the result is available asynchronously.

{#onserverallocationcreated}

onServerAllocationCreated

virtual

virtual void onServerAllocationCreated(Server * server, IAllocation * alloc)

Defined in src/turn/include/icy/turn/server/server.h:101

Called after a new allocation is successfully created.

Parameters

  • server The server that owns the allocation.

  • alloc The newly created allocation (lifetime managed by the server).


{#onserverallocationremoved}

onServerAllocationRemoved

virtual

virtual void onServerAllocationRemoved(Server * server, IAllocation * alloc)

Defined in src/turn/include/icy/turn/server/server.h:106

Called just before an allocation is destroyed (expired, deleted, or server stopped).

Parameters

  • server The server that owned the allocation.

  • alloc The allocation being removed; do not delete this pointer.


{#authenticaterequest-1}

authenticateRequest

virtual

virtual AuthenticationState authenticateRequest(Server * server, Request & request)

Defined in src/turn/include/icy/turn/server/server.h:115

Authenticates an incoming STUN request using the long-term credential mechanism (RFC 5389 section 10.2). Return Authorized to proceed, NotAuthorized to reject with a 401, QuotaReached to reject with a 486, or Authenticating to defer until the result is available asynchronously.

Parameters

  • server The server receiving the request.

  • request The STUN request to authenticate.

Returns

An AuthenticationState indicating how to proceed.

{#serveroptions}

ServerOptions

#include <icy/turn/server/server.h>
struct ServerOptions

Defined in src/turn/include/icy/turn/server/server.h:53

Configuration options for the TURN server.

List of all members

NameKindOwner
softwarevariableDeclared here
realmvariableDeclared here
allocationDefaultLifetimevariableDeclared here
allocationMaxLifetimevariableDeclared here
allocationMaxPermissionsvariableDeclared here
timerIntervalvariableDeclared here
earlyMediaBufferSizevariableDeclared here
listenAddrvariableDeclared here
externalIPvariableDeclared here
enableTCPvariableDeclared here
enableUDPvariableDeclared here
enableLocalIPPermissionsvariableDeclared here
ServerOptionsfunctionDeclared here

Public Attributes

ReturnNameDescription
std::stringsoftware
std::stringrealm
uint32_tallocationDefaultLifetime
uint32_tallocationMaxLifetime
intallocationMaxPermissions
inttimerInterval
intearlyMediaBufferSize
net::AddresslistenAddrThe TCP and UDP bind() address.
std::stringexternalIPThe external public facing IP address of the server.
boolenableTCP
boolenableUDP
boolenableLocalIPPermissionsAuto-grant permissions for RFC 1918/loopback addresses.

{#software-1}

software

std::string software

Defined in src/turn/include/icy/turn/server/server.h:55


{#realm}

realm

std::string realm

Defined in src/turn/include/icy/turn/server/server.h:56


{#allocationdefaultlifetime}

allocationDefaultLifetime

uint32_t allocationDefaultLifetime

Defined in src/turn/include/icy/turn/server/server.h:58


{#allocationmaxlifetime}

allocationMaxLifetime

uint32_t allocationMaxLifetime

Defined in src/turn/include/icy/turn/server/server.h:59


{#allocationmaxpermissions}

allocationMaxPermissions

int allocationMaxPermissions

Defined in src/turn/include/icy/turn/server/server.h:60


{#timerinterval-1}

timerInterval

int timerInterval

Defined in src/turn/include/icy/turn/server/server.h:61


{#earlymediabuffersize}

earlyMediaBufferSize

int earlyMediaBufferSize

Defined in src/turn/include/icy/turn/server/server.h:62


{#listenaddr}

listenAddr

net::Address listenAddr

Defined in src/turn/include/icy/turn/server/server.h:64

The TCP and UDP bind() address.


{#externalip}

externalIP

std::string externalIP

Defined in src/turn/include/icy/turn/server/server.h:65

The external public facing IP address of the server.


{#enabletcp}

enableTCP

bool enableTCP

Defined in src/turn/include/icy/turn/server/server.h:67


{#enableudp}

enableUDP

bool enableUDP

Defined in src/turn/include/icy/turn/server/server.h:68


{#enablelocalippermissions}

enableLocalIPPermissions

bool enableLocalIPPermissions

Defined in src/turn/include/icy/turn/server/server.h:69

Auto-grant permissions for RFC 1918/loopback addresses.

Public Methods

ReturnNameDescription
ServerOptions inline

{#serveroptions-1}

ServerOptions

inline

inline ServerOptions()

Defined in src/turn/include/icy/turn/server/server.h:71

{#tcpclientobserver}

TCPClientObserver

#include <icy/turn/client/tcpclient.h>
struct TCPClientObserver

Defined in src/turn/include/icy/turn/client/tcpclient.h:31

Inherits: ClientObserver

Observer interface for TCP TURN client events (RFC 6062). Extends ClientObserver with callbacks specific to TCP relay connections.

List of all members

NameKindOwner
onRelayConnectionCreatedfunctionDeclared here
onRelayConnectionErrorfunctionDeclared here
onRelayConnectionClosedfunctionDeclared here
onRelayConnectionBindingFailedfunctionDeclared here
onPeerConnectionAttemptfunctionDeclared here
onClientStateChangefunctionInherited from ClientObserver
onRelayDataReceivedfunctionInherited from ClientObserver
onAllocationFailedfunctionInherited from ClientObserver
onAllocationDeletedfunctionInherited from ClientObserver
onAllocationPermissionsCreatedfunctionInherited from ClientObserver
onTransactionResponsefunctionInherited from ClientObserver
onTimerfunctionInherited from ClientObserver

Inherited from ClientObserver

KindNameDescription
functiononClientStateChange virtualCalled whenever the client's state machine transitions to a new state.
functiononRelayDataReceived virtualCalled when relayed data is received from a peer via a Data Indication.
functiononAllocationFailed virtual inlineCalled when the server rejects an Allocate request with an error.
functiononAllocationDeleted virtual inlineCalled when the server confirms deletion of the allocation.
functiononAllocationPermissionsCreated virtual inlineCalled after a CreatePermission request succeeds.
functiononTransactionResponse virtual inlineAll received transaction responses will be routed here after local processing so the observer can easily implement extra functionality.
functiononTimer virtual inlineFires after the client's internal timer callback. Handy for performing extra async cleanup tasks.

Public Methods

ReturnNameDescription
voidonRelayConnectionCreated virtualCalled when a ConnectionBind succeeds and the relay pipe is live.
voidonRelayConnectionError virtual inlineCalled when an error occurs on a relay connection socket.
voidonRelayConnectionClosed virtualCalled when a relay connection socket is closed.
voidonRelayConnectionBindingFailed virtual inlineCalled when a Connect request (client-initiated) or a ConnectionBind handshake fails for the given peer.
boolonPeerConnectionAttempt virtual inlineCalled when the server sends a ConnectionAttempt indication indicating that a remote peer wants to connect. Return true to accept the connection (proceeds with ConnectionBind), or false to reject it.

{#onrelayconnectioncreated}

onRelayConnectionCreated

virtual

virtual void onRelayConnectionCreated(TCPClient & client, const net::TCPSocket::Ptr & socket, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/client/tcpclient.h:38

Called when a ConnectionBind succeeds and the relay pipe is live.

Parameters

  • client The owning TCP client.

  • socket The TCP socket that is now connected to the TURN server and ready for direct data transfer to/from the peer.

  • peerAddress The remote peer address associated with this connection.


{#onrelayconnectionerror-1}

onRelayConnectionError

virtual inline

virtual inline void onRelayConnectionError(TCPClient & client, const net::TCPSocket::Ptr & socket, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/client/tcpclient.h:44

Called when an error occurs on a relay connection socket.

Parameters

  • client The owning TCP client.

  • socket The affected socket.

  • peerAddress The remote peer address for this connection.


{#onrelayconnectionclosed-1}

onRelayConnectionClosed

virtual

virtual void onRelayConnectionClosed(TCPClient & client, const net::TCPSocket::Ptr & socket, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/client/tcpclient.h:50

Called when a relay connection socket is closed.

Parameters

  • client The owning TCP client.

  • socket The closed socket.

  • peerAddress The remote peer address for this connection.


{#onrelayconnectionbindingfailed}

onRelayConnectionBindingFailed

virtual inline

virtual inline void onRelayConnectionBindingFailed(TCPClient & client, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/client/tcpclient.h:56

Called when a Connect request (client-initiated) or a ConnectionBind handshake fails for the given peer.

Parameters

  • client The owning TCP client.

  • peerAddress The peer address whose binding failed.


{#onpeerconnectionattempt}

onPeerConnectionAttempt

virtual inline

virtual inline bool onPeerConnectionAttempt(TCPClient & client, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/client/tcpclient.h:64

Called when the server sends a ConnectionAttempt indication indicating that a remote peer wants to connect. Return true to accept the connection (proceeds with ConnectionBind), or false to reject it.

Parameters

  • client The owning TCP client.

  • peerAddress The address of the connecting peer.

Returns

true to accept and bind, false to ignore.