Peer-side TURN lifecycle: allocate, refresh, unwrap, and encode relay traffic.
How this fits
When local candidates include relay addresses, the Peer must keep TURN allocations alive, create permissions / channel bindings toward the selected remote, and wrap outbound UDP (including DTLS/SRTP) as Send Indication or ChannelData. Inbound TURN Data Indications are unwrapped before demux.
Pure helpers and state transforms used by XGW.Peer (not a GenServer).
RFCs
- RFC 8656 -- TURN allocations, permissions, ChannelBind, Send Indication, ChannelData
- RFC 8489 -- STUN encoding of TURN methods
Summary
Functions
Returns true when every relay local candidate has a covering TURN allocation.
Returns true when peer state allocations cover current ICE relay locals.
Merges gather_relay results into ICE/allocations and notifies the handler.
Cancels the TURN refresh timer when present.
Resets channel number maps.
Deletes all TURN allocations and clears channel maps.
Encodes app data as Send Indication or ChannelData for the peer.
Looks up a TURN allocation by relay local candidate.
Synchronous relay gather for prefetch.
After nomination on a relay pair, create permission + ChannelBind.
Deletes allocations when they do not cover answer relay locals.
Best-effort TURN Refresh for each live allocation.
Allocation used for outbound relay send, or nil when host path should win.
Arms :turn_refresh_tick from the first allocation lifetime.
Unwraps a TURN Data Indication to {inner, peer_from} or :not_turn_data.
Functions
Returns true when every relay local candidate has a covering TURN allocation.
Returns true when peer state allocations cover current ICE relay locals.
Merges gather_relay results into ICE/allocations and notifies the handler.
Schedules TURN refresh; caller schedules connectivity-check ticks.
Cancels the TURN refresh timer when present.
Resets channel number maps.
Deletes all TURN allocations and clears channel maps.
Encodes app data as Send Indication or ChannelData for the peer.
Looks up a TURN allocation by relay local candidate.
Synchronous relay gather for prefetch.
After nomination on a relay pair, create permission + ChannelBind.
Deletes allocations when they do not cover answer relay locals.
Best-effort TURN Refresh for each live allocation.
Allocation used for outbound relay send, or nil when host path should win.
Arms :turn_refresh_tick from the first allocation lifetime.
Unwraps a TURN Data Indication to {inner, peer_from} or :not_turn_data.