Home
TURN module (rfc5766)

ServerAllocation

Server-side TURN allocation that tracks permissions, lifetime, and relay state.

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
~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
operator=functionDeclared here
ServerAllocationfunctionDeclared here
operator=functionDeclared here
operator<<friendInherited from IAllocation
IAllocationfunctionInherited from IAllocation
~IAllocationfunctionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
operator=functionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
operator=functionInherited 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
function~IAllocation virtual
functionIAllocationDeleted constructor.
functionoperator=Deleted assignment operator.
functionIAllocationDeleted constructor.
functionoperator=Deleted assignment operator.
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
functiondeleted virtual constReturns true if the allocation's deleted flag is set and or if the allocation has expired.
functionbandwidthLimit virtual const
functionbandwidthUsed virtual const
functionbandwidthRemaining virtual const
functiontimeRemaining virtual const
functiontuple virtual
functionusername virtual const
functionlifetime virtual const
functionpermissions virtual const
functionrelayedAddress virtual const
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 virtualChecks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted.
functionhasPermission virtualChecks 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

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.
boolonTimerPeriodic maintenance callback called by Server::onTimer(). Removes expired permissions. Returns false to signal that this allocation should be destroyed.
std::int64_ttimeRemaining virtual const override
std::int64_tmaxTimeRemaining const
boolhasPermission virtual overrideChecks permission, auto-granting local IPs if enabled in server options.
boolhasPermission virtual 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 inlineReturns 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)

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

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

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

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

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

virtual const override

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

const

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

virtual override

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

virtual override

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

virtual

virtual Server & server()

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

Returns

Reference to the owning TURN server.


print

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

const inline

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

uint32_t _maxLifetime

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


_server

Server & _server

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


_permissionPolicy

PermissionPolicy _permissionPolicy

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


_refreshDeleteRequested

bool _refreshDeleteRequested = false

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

Private Methods

ReturnNameDescription
ServerAllocationNonCopyable and NonMovable.
ServerAllocationDeleted constructor.

ServerAllocation

ServerAllocation(const ServerAllocation &) = delete

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

NonCopyable and NonMovable.


ServerAllocation

ServerAllocation(ServerAllocation &&) = delete

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

Deleted constructor.