Xirsys.XTurn.RelayFamily (xturn v2.0.0)

Copy Markdown View Source

Gates peer and refresh operations by active relay address family.

What problem this solves

A dual-stack allocation may hold both IPv4 and IPv6 relay sockets. CreatePermission and ChannelBind must reject peers whose IP version has no active relay path. Refresh with REQUESTED-ADDRESS-FAMILY must only extend lifetimes for families that still exist on the allocation.

Internal note

Called from TURN action modules during permission, channel, and refresh handling.

RFCs

  • RFC 8656 (multi-family allocations and refresh)
  • RFC 5766 (permissions and channels)

Summary

Functions

Returns whether a peer address matches one of the allocation's active families.

Returns whether a REQUESTED-ADDRESS-FAMILY value is still active on the allocation.

Functions

peer_allowed?(peer_address, active_families)

Returns whether a peer address matches one of the allocation's active families.

Examples

iex> Xirsys.XTurn.RelayFamily.peer_allowed?({{127, 0, 0, 1}, 1234}, [4])
true

iex> Xirsys.XTurn.RelayFamily.peer_allowed?({{127, 0, 0, 1}, 1234}, [8])
false

iex> Xirsys.XTurn.RelayFamily.peer_allowed?({{127, 0, 0, 1}, 1234}, :invalid)
false

refresh_family_active?(raf, active_families)

Returns whether a REQUESTED-ADDRESS-FAMILY value is still active on the allocation.

Examples

iex> alias Xirsys.XTurn.{AddressFamily, RelayFamily}
iex> RelayFamily.refresh_family_active?(AddressFamily.ipv4(), [4, 8])
true

iex> Xirsys.XTurn.RelayFamily.refresh_family_active?(Xirsys.XTurn.AddressFamily.ipv6(), [4])
false