TCPAllocation
TCPAllocation
#include <icy/turn/server/tcpallocation.h>class TCPAllocationDefined 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
| Name | Kind | Owner |
|---|---|---|
TCPAllocation | function | Declared here |
~TCPAllocation | function | Declared here |
handleRequest | function | Declared here |
handleConnectRequest | function | Declared here |
handleConnectionBindRequest | function | Declared here |
sendPeerConnectResponse | function | Declared here |
sendToControl | function | Declared here |
control | function | Declared here |
relayedAddress | function | Declared here |
pairs | function | Declared here |
onTimer | function | Declared here |
onPeerAccept | function | Declared here |
onControlClosed | function | Declared here |
_control | variable | Declared here |
_acceptor | variable | Declared here |
_pairs | variable | Declared here |
Server | friend | Inherited from ServerAllocation |
ServerAllocation | function | Inherited from ServerAllocation |
~ServerAllocation | function | Inherited from ServerAllocation |
handleRequest | function | Inherited from ServerAllocation |
handleRefreshRequest | function | Inherited from ServerAllocation |
handleCreatePermission | function | Inherited from ServerAllocation |
onTimer | function | Inherited from ServerAllocation |
timeRemaining | function | Inherited from ServerAllocation |
maxTimeRemaining | function | Inherited from ServerAllocation |
hasPermission | function | Inherited from ServerAllocation |
hasPermission | function | Inherited from ServerAllocation |
server | function | Inherited from ServerAllocation |
print | function | Inherited from ServerAllocation |
refreshDeleteRequested | function | Inherited from ServerAllocation |
_maxLifetime | variable | Inherited from ServerAllocation |
_server | variable | Inherited from ServerAllocation |
_permissionPolicy | variable | Inherited from ServerAllocation |
_refreshDeleteRequested | variable | Inherited from ServerAllocation |
ServerAllocation | function | Inherited from ServerAllocation |
operator= | function | Inherited from ServerAllocation |
ServerAllocation | function | Inherited from ServerAllocation |
operator= | function | Inherited from ServerAllocation |
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 ServerAllocation
| Kind | Name | Description |
|---|---|---|
friend | Server | |
function | ServerAllocation | |
function | ~ServerAllocation virtual | |
function | handleRequest virtual | Dispatches incoming STUN requests to handleCreatePermission() or handleRefreshRequest(). Subclasses override to add transport-specific methods. |
function | handleRefreshRequest virtual | Processes a Refresh request; updates the lifetime or sets the delete flag if the requested lifetime is 0, then sends a success response. |
function | handleCreatePermission virtual | Processes a CreatePermission request; installs or refreshes permissions for each XOR-PEER-ADDRESS attribute, then sends a success response. |
function | onTimer | Periodic maintenance callback called by Server::onTimer(). Removes expired permissions. Returns false to signal that this allocation should be destroyed. |
function | timeRemaining virtual const override | |
function | maxTimeRemaining const | |
function | hasPermission virtual override | Checks permission, auto-granting local IPs if enabled in server options. |
function | hasPermission virtual override | Checks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only. |
function | server virtual | |
function | print virtual const override | Writes a detailed diagnostic dump of this allocation to os. |
function | refreshDeleteRequested const inline | Returns 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 | |
function | ServerAllocation | NonCopyable and NonMovable. |
function | operator= | Deleted assignment operator. |
function | ServerAllocation | Deleted constructor. |
function | operator= | Deleted assignment operator. |
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 |
|---|---|---|
TCPAllocation | ||
bool | handleRequest virtual | Extends the base handler with Connect and ConnectionBind methods. |
void | handleConnectRequest | Handles a Connect request; creates a TCPConnectionPair and initiates a TCP connection to the peer address carried in XOR-PEER-ADDRESS. |
void | handleConnectionBindRequest | Handles a ConnectionBind request; associates the incoming TCP data socket with the pending TCPConnectionPair and activates the relay pipe. |
void | sendPeerConnectResponse | Sends a Connect success or failure response to the control connection. |
ssize_t | sendToControl | Sends a STUN message to the client over the control TCP connection. |
net::TCPSocket & | control | |
net::Address | relayedAddress virtual const | |
TCPConnectionPairMap & | pairs | |
bool | onTimer | Periodic timer callback; removes expired or pending-delete connection pairs, then calls the base class timer. |
void | onPeerAccept | Accepts incoming peer sockets on the relay acceptor socket. Checks permissions and sends a ConnectionAttempt indication to the control. |
bool | onControlClosed | Called when the control connection closes; marks the allocation for deletion. |
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
serverOwning TURN server.controlThe accepted TCP socket used for STUN control messages.tuple5-tuple identifying this allocation.usernameAuthenticated username from the Allocate request.lifetimeInitial lifetime in seconds.
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
requestIncoming STUN request.
Returns
true if handled.
Reimplements
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
requestIncoming Connect request.
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
requestIncoming ConnectionBind request.
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
pairThe connection pair whose peer connection attempt completed.successtrue if the peer TCP connection succeeded.
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
messageMessage to send.
Returns
Number of bytes sent, or a negative value on error.
control
net::TCPSocket & control()Defined in src/turn/include/icy/turn/server/tcpallocation.h:75
Returns
Reference to the TCP control socket.
relayedAddress
virtual const
virtual net::Address relayedAddress() constDefined 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
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
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
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
sockNewly accepted peer socket.
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
socketThe closed control socket.
Returns
false (event propagation convention).
Protected Attributes
| Return | Name | Description |
|---|---|---|
net::SocketEmitter | _control | |
net::SocketEmitter | _acceptor | |
TCPConnectionPairMap | _pairs |
_control
net::SocketEmitter _controlDefined in src/turn/include/icy/turn/server/tcpallocation.h:99
_acceptor
net::SocketEmitter _acceptorDefined in src/turn/include/icy/turn/server/tcpallocation.h:100
_pairs
TCPConnectionPairMap _pairsDefined in src/turn/include/icy/turn/server/tcpallocation.h:101
