Xirsys.XTurn.RelayIngress (xturn v2.0.0)

Copy Markdown View Source

Sharded supervisor for peer -> client relay ingress.

What problem this solves

When a peer sends UDP to the relay address, the server must deliver that payload back to the TURN client (as ChannelData or a Data indication). Relay sockets are sharded across workers by port so each GenServer drains its own {active, N} batch without mailbox contention.

assign_socket/2 moves relay socket ownership to the correct worker via controlling_process/2; workers permission-check, optionally run plugins, and send to the client through DataPlane.to_client/4.

Internal

Started under the application supervision tree; not called by integrators except indirectly during allocation setup.

RFCs

  • RFC 5766 - relayed transport address and peer -> client delivery (pt.2, pt.10, pt.11)

Summary

Functions

Assigns socket to the worker shard for port.

Number of relay ingress worker shards.

Starts the shard supervisor (one_for_one).

Registered name for shard index (xturn_relay_ingress_N).

Returns the PID of the worker shard that owns relay traffic on port.

Functions

assign_socket(socket, port)

Assigns socket to the worker shard for port.

Returns :ok on success or {:error, :no_worker} when the shard is not running.

shard_count()

Number of relay ingress worker shards.

Configured via :udp_listen_shards (defaults to System.schedulers_online/0).

start_link()

Starts the shard supervisor (one_for_one).

via(index)

Registered name for shard index (xturn_relay_ingress_N).

worker_for_port(port)

Returns the PID of the worker shard that owns relay traffic on port.