#include <icy/turn/server/tcpallocation.h>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.
| Return | Name | Description |
|---|---|---|
TCPAllocation | #### Parameters | |
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 | #### Returns |
net::Address | relayedAddress virtual const | #### Returns |
TCPConnectionPairMap & | pairs | #### Returns |
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(Server & server, const net::Socket::Ptr & control, const FiveTuple & tuple, const std::string & username, const uint32_t & lifetime)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.
virtual
virtual bool handleRequest(Request & request)Extends the base handler with Connect and ConnectionBind methods.
request Incoming STUN request.true if handled.
void handleConnectRequest(Request & request)Handles a Connect request; creates a TCPConnectionPair and initiates a TCP connection to the peer address carried in XOR-PEER-ADDRESS.
request Incoming Connect request.void handleConnectionBindRequest(Request & request)Handles a ConnectionBind request; associates the incoming TCP data socket with the pending TCPConnectionPair and activates the relay pipe.
request Incoming ConnectionBind request.void sendPeerConnectResponse(TCPConnectionPair * pair, bool success)Sends a Connect success or failure response to the control connection.
pair The connection pair whose peer connection attempt completed.
success true if the peer TCP connection succeeded.
ssize_t sendToControl(stun::Message & message)Sends a STUN message to the client over the control TCP connection.
message Message to send.Number of bytes sent, or a negative value on error.
net::TCPSocket & control()Reference to the TCP control socket.
virtual const
virtual net::Address relayedAddress() constThe listen address of the peer acceptor socket (used as the relayed address).
TCPConnectionPairMap & pairs()Reference to the map of active TCPConnectionPairs keyed by connection ID.
bool onTimer()Periodic timer callback; removes expired or pending-delete connection pairs, then calls the base class timer.
false if the allocation should be destroyed.
void onPeerAccept(const net::TCPSocket::Ptr & sock)Accepts incoming peer sockets on the relay acceptor socket. Checks permissions and sends a ConnectionAttempt indication to the control.
sock Newly accepted peer socket.bool onControlClosed(net::Socket & socket)Called when the control connection closes; marks the allocation for deletion.
socket The closed control socket.false (event propagation convention).
| Return | Name | Description |
|---|---|---|
net::SocketEmitter | _control | |
net::SocketEmitter | _acceptor | |
TCPConnectionPairMap | _pairs |
net::SocketEmitter _controlnet::SocketEmitter _acceptorTCPConnectionPairMap _pairs