Resolves STUN/TURN listen ports and default bind tuples.
What problem this solves
The server must listen on well-known STUN/TURN ports (typically 3478 UDP/TCP
and 5349 for TLS) on the configured host addresses. Operators set :listen in
application env or rely on defaults; this module centralises port resolution
from env vars and rewrites listen specs at boot so config stays consistent.
RFCs
Summary
Functions
Appends plain and secure IPv6 listen entries for ip6 to an existing list.
Returns true when :certs config points at an existing certificate file.
Default listen list: 0.0.0.0 and :: for plain and (when certs exist) TLS.
Returns UDP and TCP plain listener tuples on ip at turn_port/0.
Rewrites all listen tuple ports using current turn_port/0 and turns_port/0.
Rewrites listen tuple ports to explicit plain and TLS port numbers.
Returns UDP and TCP TLS listener tuples on ip, or [] when certs? is false.
STUN/TURN plain (non-TLS) listen port.
TURNS (TLS) listen port.
Functions
Appends plain and secure IPv6 listen entries for ip6 to an existing list.
@spec certs_available?() :: boolean()
Returns true when :certs config points at an existing certificate file.
Default listen list: 0.0.0.0 and :: for plain and (when certs exist) TLS.
Pass certs? false to omit secure entries even if files are present.
@spec plain_entries(charlist()) :: [{atom(), charlist(), pos_integer()}]
Returns UDP and TCP plain listener tuples on ip at turn_port/0.
Rewrites all listen tuple ports using current turn_port/0 and turns_port/0.
@spec rewrite_ports(list(), pos_integer(), pos_integer()) :: list()
Rewrites listen tuple ports to explicit plain and TLS port numbers.
@spec secure_entries( charlist(), boolean() ) :: [{atom(), charlist(), pos_integer(), :secure}]
Returns UDP and TCP TLS listener tuples on ip, or [] when certs? is false.
@spec turn_port() :: pos_integer()
STUN/TURN plain (non-TLS) listen port.
Reads XTURN_STUN_PORT, then :stun_port application env, then defaults to 3478.
@spec turns_port() :: pos_integer()
TURNS (TLS) listen port.
Reads XTURN_TURNS_PORT or defaults to 5349.