ServerAllocation
ServerAllocation
#include <icy/turn/server/serverallocation.h>Inherits:
IAllocationSubclassed 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.
Public Methods
| Return | Name | Description |
|---|---|---|
ServerAllocation | #### Parameters | |
bool | handleRequest virtual | Dispatches incoming STUN requests to handleCreatePermission() or handleRefreshRequest(). Subclasses override to add transport-specific methods. |
void | 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. |
void | handleCreatePermission virtual | Processes a CreatePermission request; installs or refreshes permissions for each XOR-PEER-ADDRESS attribute, then sends a success response. |
bool | onTimer | Periodic maintenance callback called by Server::onTimer(). Removes expired permissions. Returns false to signal that this allocation should be destroyed. |
std::int64_t | timeRemaining virtual const | #### Returns |
std::int64_t | maxTimeRemaining const | #### Returns |
bool | hasPermission virtual | Checks permission, auto-granting local IPs if enabled in server options. |
bool | hasPermission virtual | Checks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only. |
Server & | server virtual | #### Returns |
void | print virtual const | Writes a detailed diagnostic dump of this allocation to os. |
bool | refreshDeleteRequested const inline | Returns true if the refresh request set lifetime to 0, signaling the parent Server to delete this allocation. |
ServerAllocation
ServerAllocation(Server & server, const FiveTuple & tuple, const std::string & username, std::int64_t lifetime)Parameters
serverOwning TURN server.tuple5-tuple uniquely identifying this allocation.usernameAuthenticated username from the Allocate request.lifetimeInitial lifetime in seconds as negotiated with the client.
handleRequest
virtual
virtual bool handleRequest(Request & request)Dispatches incoming STUN requests to handleCreatePermission() or handleRefreshRequest(). Subclasses override to add transport-specific methods.
Parameters
requestIncoming STUN request.
Returns
true if the request was handled; false signals the server to respond with a 600 "Operation Not Supported" error.
handleRefreshRequest
virtual
virtual void handleRefreshRequest(Request & request)Processes a Refresh request; updates the lifetime or sets the delete flag if the requested lifetime is 0, then sends a success response.
Parameters
requestIncoming Refresh request.
handleCreatePermission
virtual
virtual void handleCreatePermission(Request & request)Processes a CreatePermission request; installs or refreshes permissions for each XOR-PEER-ADDRESS attribute, then sends a success response.
Parameters
requestIncoming CreatePermission request.
onTimer
bool onTimer()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
virtual const
virtual std::int64_t timeRemaining() constReturns
The lesser of IAllocation::timeRemaining() and maxTimeRemaining().
maxTimeRemaining
const
std::int64_t maxTimeRemaining() constReturns
Seconds remaining before the server-enforced maximum lifetime expires.
hasPermission
virtual
virtual bool hasPermission(const std::string & peerIP)Checks permission, auto-granting local IPs if enabled in server options.
hasPermission
virtual
virtual bool hasPermission(const net::Address & peerAddress)Checks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
server
virtual
virtual Server & server()Returns
Reference to the owning TURN server.
virtual const
virtual void print(std::ostream & os) constWrites a detailed diagnostic dump of this allocation to os.
refreshDeleteRequested
const inline
inline bool refreshDeleteRequested() constReturns true if the refresh request set lifetime to 0, signaling the parent Server to delete this allocation.
Protected Attributes
| Return | Name | Description |
|---|---|---|
uint32_t | _maxLifetime | |
Server & | _server | |
PermissionPolicy | _permissionPolicy | |
bool | _refreshDeleteRequested |
_maxLifetime
uint32_t _maxLifetime_server
Server & _server_permissionPolicy
PermissionPolicy _permissionPolicy_refreshDeleteRequested
bool _refreshDeleteRequested = falsePrivate Methods
| Return | Name | Description |
|---|---|---|
ServerAllocation | NonCopyable and NonMovable. | |
ServerAllocation | Deleted constructor. |
ServerAllocation
ServerAllocation(const ServerAllocation &) = deleteNonCopyable and NonMovable.
ServerAllocation
ServerAllocation(ServerAllocation &&) = deleteDeleted constructor.
