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

Copy Markdown View Source

ETS index of active TURN allocations and relay ingress rows.

What problem this solves

Control handlers, the data plane, and relay ingress must find the allocation process, client socket, and channel map quickly from a transaction id, client five-tuple, or inbound relay {ip, port}. This store holds those mappings and publishes relay socket rows for peer-to-client forwarding.

Internal note

Initialised at application start; rows are inserted/deleted by Allocate.Client.

RFCs

  • RFC 5766 (allocation identity and relay address)
  • RFC 6062 (TCP allocation flag in tuple5 index)

Summary

Functions

Deletes an allocation or raw ETS row.

Returns true when lookup/1 would succeed for criteria.

Creates the public allocation ETS table.

Inserts a new allocation under tid and indexes it by normalized tuple5.

Looks up an allocation by one of

Functions

delete(key)

Deletes an allocation or raw ETS row.

When key is a transaction id, unpublishes relay rows and removes the {:tuple5, _} secondary index. Any other key is deleted directly.

exists(criteria)

Returns true when lookup/1 would succeed for criteria.

init()

Creates the public allocation ETS table.

insert(tid, pid, relay, tuple5, socket, perms)

Inserts a new allocation under tid and indexes it by normalized tuple5.

Returns :ok.

lookup(tid)

Looks up an allocation by one of:

  • transaction id (tid) - {:ok, pid, socket, perms}
  • normalized five-tuple list - {:ok, [pid, relay, socket, perms]}
  • relay {ip, port} - {:ok, [pid, tuple5, socket, perms]}

Returns {:error, :not_found} when no match exists.