Opens relay UDP ports according to server port policy.
What problem this solves
Each TURN allocation needs one or more UDP ports on the server to relay traffic. Clients may request random ports, a preferred port, a range, or RFC 8656 even-port allocation with an optional reserved adjacent port. This module implements those bind policies on top of the socket transport layer.
Internal note
Called from Allocate.Client during Allocate success handling.
RFCs
Summary
Functions
Opens a relay UDP socket on server_ip using policy.
Opens an even relay UDP port, optionally reserving the next odd port.
Functions
@spec open(:inet.ip_address(), term(), keyword()) :: {:ok, port()} | {:error, term()}
Opens a relay UDP socket on server_ip using policy.
policy may be :random, {:preferred, port}, or {:range, min, max}.
Returns {:ok, socket} or {:error, reason}.
@spec open_even(:inet.ip_address(), boolean(), keyword()) :: {:ok, port(), non_neg_integer(), binary() | nil} | {:error, term()}
Opens an even relay UDP port, optionally reserving the next odd port.
When reserve_next? is true, returns an 8-byte token for the reserved
adjacent port. Returns {:ok, socket, port, token} or {:error, reason}.