TURN module (rfc5766)

ServerObserver

Observer interface that the application must implement to participate in server-side allocation management and authentication.

ServerObserver

#include <icy/turn/server/server.h>

Observer interface that the application must implement to participate in server-side allocation management and authentication.

The observer is responsible for enforcing per-user allocation quotas and bandwidth limits. Implementations may perform authentication synchronously (returning Authorized/NotAuthorized immediately) or asynchronously (returning Authenticating and calling handleRequest() again later).

Public Methods

ReturnNameDescription
voidonServerAllocationCreatedCalled after a new allocation is successfully created.
voidonServerAllocationRemovedCalled just before an allocation is destroyed (expired, deleted, or server stopped).
AuthenticationStateauthenticateRequestAuthenticates an incoming STUN request using the long-term credential mechanism (RFC 5389 section 10.2). Return Authorized to proceed, NotAuthorized to reject with a 401, QuotaReached to reject with a 486, or Authenticating to defer until the result is available asynchronously.

onServerAllocationCreated

void onServerAllocationCreated(Server * server, IAllocation * alloc)

Called after a new allocation is successfully created.

Parameters

  • server The server that owns the allocation.

  • alloc The newly created allocation (lifetime managed by the server).


onServerAllocationRemoved

void onServerAllocationRemoved(Server * server, IAllocation * alloc)

Called just before an allocation is destroyed (expired, deleted, or server stopped).

Parameters

  • server The server that owned the allocation.

  • alloc The allocation being removed; do not delete this pointer.


authenticateRequest

AuthenticationState authenticateRequest(Server * server, Request & request)

Authenticates an incoming STUN request using the long-term credential mechanism (RFC 5389 section 10.2). Return Authorized to proceed, NotAuthorized to reject with a 401, QuotaReached to reject with a 486, or Authenticating to defer until the result is available asynchronously.

Parameters

  • server The server receiving the request.

  • request The STUN request to authenticate.

Returns

An AuthenticationState indicating how to proceed.