TURN module (rfc5766)
UDPClient
UDP transport TURN client for datagram-based relay allocations.
UDPClient
#include <icy/turn/client/udpclient.h>class UDPClientDefined 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
| Name | Kind | Owner |
|---|---|---|
UDPClient | function | Declared here |
~UDPClient | function | Declared here |
Client | function | Inherited from Client |
~Client | function | Inherited from Client |
start | function | Inherited from Client |
stop | function | Inherited from Client |
sendAllocate | function | Inherited from Client |
addPermission | function | Inherited from Client |
addPermission | function | Inherited from Client |
sendCreatePermission | function | Inherited from Client |
sendChannelBind | function | Inherited from Client |
sendRefresh | function | Inherited from Client |
sendData | function | Inherited from Client |
handleResponse | function | Inherited from Client |
handleAllocateResponse | function | Inherited from Client |
handleAllocateErrorResponse | function | Inherited from Client |
handleCreatePermissionResponse | function | Inherited from Client |
handleCreatePermissionErrorResponse | function | Inherited from Client |
handleRefreshResponse | function | Inherited from Client |
handleDataIndication | function | Inherited from Client |
transportProtocol | function | Inherited from Client |
createTransaction | function | Inherited from Client |
authenticateRequest | function | Inherited from Client |
sendAuthenticatedTransaction | function | Inherited from Client |
removeTransaction | function | Inherited from Client |
mappedAddress | function | Inherited from Client |
relayedAddress | function | Inherited from Client |
closed | function | Inherited from Client |
observer | function | Inherited from Client |
options | function | Inherited from Client |
addPermission | function | Inherited from Client |
addPermission | function | Inherited from Client |
hasPermission | function | Inherited from Client |
hasPermission | function | Inherited from Client |
removePermission | function | Inherited from Client |
removePermission | function | Inherited from Client |
_observer | variable | Inherited from Client |
_options | variable | Inherited from Client |
_socket | variable | Inherited from Client |
_timer | variable | Inherited from Client |
_error | variable | Inherited from Client |
_mappedAddress | variable | Inherited from Client |
_relayedAddress | variable | Inherited from Client |
_realm | variable | Inherited from Client |
_nonce | variable | Inherited from Client |
_pendingIndications | variable | Inherited from Client |
_transactions | variable | Inherited from Client |
setError | function | Inherited from Client |
onSocketConnect | function | Inherited from Client |
onSocketRecv | function | Inherited from Client |
onSocketClose | function | Inherited from Client |
onTransactionProgress | function | Inherited from Client |
onStateChange | function | Inherited from Client |
onTimer | function | Inherited from Client |
StateChange | variable | Inherited from Stateful |
Stateful | function | Inherited from Stateful |
~Stateful | function | Inherited from Stateful |
stateEquals | function | Inherited from Stateful |
stateBetween | function | Inherited from Stateful |
state | function | Inherited from Stateful |
state | function | Inherited from Stateful |
_state | variable | Inherited from Stateful |
beforeStateChange | function | Inherited from Stateful |
onStateChange | function | Inherited from Stateful |
setState | function | Inherited from Stateful |
setState | function | Inherited from Stateful |
operator<< | friend | Inherited from IAllocation |
IAllocation | function | Inherited from IAllocation |
~IAllocation | function | Inherited from IAllocation |
IAllocation | function | Inherited from IAllocation |
operator= | function | Inherited from IAllocation |
IAllocation | function | Inherited from IAllocation |
operator= | function | Inherited from IAllocation |
updateUsage | function | Inherited from IAllocation |
setLifetime | function | Inherited from IAllocation |
setBandwidthLimit | function | Inherited from IAllocation |
expired | function | Inherited from IAllocation |
deleted | function | Inherited from IAllocation |
bandwidthLimit | function | Inherited from IAllocation |
bandwidthUsed | function | Inherited from IAllocation |
bandwidthRemaining | function | Inherited from IAllocation |
timeRemaining | function | Inherited from IAllocation |
tuple | function | Inherited from IAllocation |
username | function | Inherited from IAllocation |
lifetime | function | Inherited from IAllocation |
permissions | function | Inherited from IAllocation |
relayedAddress | function | Inherited from IAllocation |
addPermission | function | Inherited from IAllocation |
addPermission | function | Inherited from IAllocation |
addPermissions | function | Inherited from IAllocation |
removePermission | function | Inherited from IAllocation |
removePermission | function | Inherited from IAllocation |
removeAllPermissions | function | Inherited from IAllocation |
removeExpiredPermissions | function | Inherited from IAllocation |
hasPermission | function | Inherited from IAllocation |
hasPermission | function | Inherited from IAllocation |
print | function | Inherited from IAllocation |
_tuple | variable | Inherited from IAllocation |
_username | variable | Inherited from IAllocation |
_permissions | variable | Inherited from IAllocation |
_lifetime | variable | Inherited from IAllocation |
_bandwidthLimit | variable | Inherited from IAllocation |
_bandwidthUsed | variable | Inherited from IAllocation |
_createdAt | variable | Inherited from IAllocation |
_updatedAt | variable | Inherited from IAllocation |
_deleted | variable | Inherited from IAllocation |
Inherited from Client
| Kind | Name | Description |
|---|---|---|
function | Client | |
function | ~Client virtual | |
function | start virtual | Connects the socket to the TURN server and starts the allocation sequence. Permissions must be added via addPermission() before calling this. |
function | stop virtual | Stops the timer, cancels pending transactions, and closes the socket. |
function | sendAllocate virtual | 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. |
function | addPermission virtual | Adds multiple peer IP addresses to the permission list. |
function | addPermission virtual override | 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. |
function | sendCreatePermission virtual | 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. |
function | sendChannelBind virtual | 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. |
function | sendRefresh virtual | Sends a Refresh request to extend the allocation lifetime. Called automatically by the timer when roughly one-third of the lifetime remains. |
function | sendData virtual | 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. |
function | handleResponse virtual | Dispatches an incoming STUN/TURN response to the appropriate handler. |
function | handleAllocateResponse virtual | Processes a successful Allocate response; extracts mapped/relayed addresses and advances the state to Authorizing, then sends CreatePermission. |
function | handleAllocateErrorResponse virtual | Handles an Allocate error response; manages the 401 challenge/re-send flow and sets the client to Failed for unrecoverable errors. |
function | handleCreatePermissionResponse virtual | Handles a successful CreatePermission response; flushes queued Send Indications and advances state to Success. |
function | handleCreatePermissionErrorResponse virtual | Handles a failed CreatePermission response; clears all permissions and sets the client to Failed. |
function | handleRefreshResponse virtual | Handles a Refresh response; updates the stored lifetime. |
function | handleDataIndication virtual | Handles an incoming Data Indication; extracts peer address and data and forwards to ClientObserver::onRelayDataReceived(). |
function | transportProtocol virtual | |
function | createTransaction virtual | Creates a new STUN transaction, registers the progress callback, and adds it to the active transaction list. |
function | authenticateRequest virtual | Adds STUN long-term credential attributes (Username, Realm, Nonce, MessageIntegrity) to request if the realm has been received from the server. |
function | sendAuthenticatedTransaction virtual | Calls authenticateRequest() then sends the transaction. |
function | removeTransaction virtual | Removes a transaction from the active list. The IntrusivePtr keeps the object alive until the caller's copy is released. |
function | mappedAddress const | |
function | relayedAddress virtual const override | |
function | closed const | |
function | observer | |
function | options const | |
function | addPermission virtual | Adds a permission for ip, or refreshes the existing one. |
function | addPermission virtual | Adds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only. |
function | hasPermission virtual | Checks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted. |
function | hasPermission virtual | Checks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only. |
function | removePermission virtual | Removes the permission for ip if present. |
function | removePermission virtual | Removes 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 | _pendingIndications | A list of queued Send indication packets awaiting server permissions. |
variable | _transactions | A list containing currently active transactions. |
function | setError virtual | Sets the error field and transitions the client to the Failed state. |
function | onSocketConnect virtual | Socket connect callback; starts the timer and sends the first Allocate request. |
function | onSocketRecv virtual | Socket receive callback; parses STUN messages from the buffer and dispatches them. |
function | onSocketClose virtual | Socket close callback; shuts down the client and records the socket error. |
function | onTransactionProgress virtual | STUN transaction state-change callback; handles Success and Failed outcomes. |
function | onStateChange override | Forwards state-change events to the observer. |
function | onTimer virtual | Periodic timer callback; re-allocates on expiry or refreshes when lifetime is below one-third remaining. Also calls ClientObserver::onTimer(). |
Inherited from Stateful
| Kind | Name | Description |
|---|---|---|
variable | StateChange | Signals when the state changes. |
function | Stateful inline | |
function | ~Stateful virtual inline | |
function | stateEquals virtual const inline | Returns true if the current state ID equals the given ID. |
function | stateBetween virtual const inline | Returns true if the current state ID is in the inclusive range [lid, rid]. |
function | state virtual inline | Returns a mutable reference to the current state. |
function | state virtual const inline | Returns a copy of the current state. |
variable | _state | |
function | beforeStateChange virtual inline | Override to handle pre state change logic. Return false to prevent state change. |
function | onStateChange virtual inline | Override to handle post state change logic. |
function | setState virtual inline | Sets the state and sends the state signal if the state change was successful. |
function | setState virtual inline | Sets the state and sends the state signal if the state change was successful. |
Inherited from IAllocation
| Kind | Name | Description |
|---|---|---|
friend | operator<< inline | |
function | IAllocation | |
function | ~IAllocation virtual | |
function | IAllocation | Deleted constructor. |
function | operator= | Deleted assignment operator. |
function | IAllocation | Deleted constructor. |
function | operator= | Deleted assignment operator. |
function | updateUsage virtual | Updates the last-activity timestamp and accumulates bandwidth usage. Call this whenever data is relayed through the allocation. |
function | setLifetime virtual | Sets the allocation lifetime in seconds and resets the activity timestamp, effectively extending the expiry from the current moment. |
function | setBandwidthLimit virtual | Sets the maximum number of bytes this allocation may relay in its lifetime. Pass 0 to disable bandwidth limiting. |
function | expired virtual const | |
function | deleted virtual const | Returns true if the allocation's deleted flag is set and or if the allocation has expired. |
function | bandwidthLimit virtual const | |
function | bandwidthUsed virtual const | |
function | bandwidthRemaining virtual const | |
function | timeRemaining virtual const | |
function | tuple virtual | |
function | username virtual const | |
function | lifetime virtual const | |
function | permissions virtual const | |
function | relayedAddress virtual const | |
function | addPermission virtual | Adds a permission for ip, or refreshes the existing one. |
function | addPermission virtual | Adds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only. |
function | addPermissions virtual | Adds (or refreshes) permissions for multiple IPs. |
function | removePermission virtual | Removes the permission for ip if present. |
function | removePermission virtual | Removes the permission for address if present. The port is ignored; TURN permissions are IP-only. |
function | removeAllPermissions virtual | Removes all permissions from the list. |
function | removeExpiredPermissions virtual | Removes any permissions whose 5-minute lifetime has elapsed. |
function | hasPermission virtual | Checks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted. |
function | hasPermission virtual | Checks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only. |
function | print virtual const inline | |
variable | _tuple | |
variable | _username | |
variable | _permissions | |
variable | _lifetime | |
variable | _bandwidthLimit | |
variable | _bandwidthUsed | |
variable | _createdAt | |
variable | _updatedAt | |
variable | _deleted |
Public Methods
| Return | Name | Description |
|---|---|---|
UDPClient |
UDPClient
UDPClient(ClientObserver & observer, const Options & options = Options())Defined in src/turn/include/icy/turn/client/udpclient.h:36
Parameters
observerObserver for allocation lifecycle and data relay events.optionsClient configuration; defaults to loopback server, 5-min lifetime.
