Xirsys.Sockets.Config (xturn_sockets v2.0.0)

View Source

Runtime configuration for xturn_sockets.

Set config :xturn_sockets, config_app: :my_app in the host project so config :my_app, ... overrides library defaults.

Summary

Functions

Fixed-window request counter for one client IP.

Looks up configuration with precedence: host application (see :config_app), then :xturn_sockets, then default.

Receive/send buffer size for shared client-facing listener sockets (UDP/TCP accept).

Merged reorder tunables for a named tier.

Functions

check_rate_limit(client_ip)

@spec check_rate_limit(:inet.ip_address()) :: :ok | {:error, :rate_limited}

Fixed-window request counter for one client IP.

Intended for control-plane requests only. Callers must not apply this to relayed data (TURN ChannelData, Send/Data indications): media runs at hundreds of packets per second, so any request-shaped budget silently starves it within seconds.

Each IP holds a single row carrying the current window index and its count, so both the check and the update are O(1) and memory stays constant per IP.

get(key, default \\ nil)

@spec get(atom(), any()) :: any()

Looks up configuration with precedence: host application (see :config_app), then :xturn_sockets, then default.

listener_buffer_size()

@spec listener_buffer_size() :: pos_integer()

Receive/send buffer size for shared client-facing listener sockets (UDP/TCP accept).

Defaults larger than buffer_size/0 so the kernel queue can absorb bursts while worker processes drain packets. Relay sockets use their own hard-coded buffers.

reorder_opts(name, opts)

@spec reorder_opts(
  atom() | nil,
  keyword()
) :: keyword()

Merged reorder tunables for a named tier.

Precedence (lowest to highest): library defaults, :xturn_sockets tier config, host :config_app tier config, explicit keys in opts.