Xirsys.XTurn.Channels.Store (xturn v2.0.0)

Copy Markdown View Source

ETS-backed store of TURN channel bindings (client -> peer direction).

What problem this solves

When a client sends ChannelData, the server must map the channel number to the bound peer quickly. This table stores {allocation 5-tuple, channel_number} -> {worker pid, peer address, ...} for O(1) lookup on the media path.

Keys normalize the allocation :proto field so lookups match regardless of UDP vs TCP on the control socket. Peer -> client relay uses RelayIngress and Allocate.Store.lookup_sock/1 instead.

Internal

Runtime infrastructure; populated by allocation workers on ChannelBind and read by DataPlane / Actions.ChannelData.

RFCs

  • RFC 5766 - channels and ChannelBind (pt.11)

Summary

Functions

Deletes a single channel binding, scoped to the allocation identified by tuple5.

Deletes every channel binding belonging to a given allocation.

Returns true when channel cid is bound on the allocation identified by tuple5.

Creates the public channel-bindings ETS table.

Registers (or overwrites) the channel binding for {tuple5, cid}.

O(1) lookup of the channel cid bound by the allocation identified by tuple5. Returns {:ok, {pid, peer_address, socket}} or {:error, :not_found}.

Functions

delete(cid, tuple5)

Deletes a single channel binding, scoped to the allocation identified by tuple5.

delete_all(tuple5)

Deletes every channel binding belonging to a given allocation.

exists?(cid, tuple5)

Returns true when channel cid is bound on the allocation identified by tuple5.

init()

Creates the public channel-bindings ETS table.

insert(cid, pid, peer_address, tuple5, socket \\ nil, relayed_address \\ nil)

Registers (or overwrites) the channel binding for {tuple5, cid}.

lookup(cid, tuple5)

O(1) lookup of the channel cid bound by the allocation identified by tuple5. Returns {:ok, {pid, peer_address, socket}} or {:error, :not_found}.