Xirsys.XTurn.Handlers.StunTurn (xturn v2.0.0)

Copy Markdown View Source

Socket handler that multiplexes TURN control and media on one connection.

What problem this solves

Clients send STUN/TURN control messages and high-rate media (ChannelData, Send) on the same socket. This handler classifies each complete frame and routes control to worker processes while forwarding media on a fast path that avoids GenServer bottlenecks. Only STUN requests count toward the per-IP rate limit so relay traffic does not stall control.

Internal

Registered as the :handler tier in SocketPipeline; not called by application code directly.

RFCs

  • RFC 5389 - STUN message classes (request vs indication)
  • RFC 5766 - ChannelData and Send on client socket (pt.11)
  • RFC 6062 - ConnectionBind on TCP data connection

Summary

Functions

Classifies and routes one complete frame from the client socket.

Functions

handle_packet(frame, meta, sock_conn, state)

Classifies and routes one complete frame from the client socket.

Media (ChannelData, Send) is forwarded via DataPlane; control STUN is dispatched to the client worker pool. ConnectionBind on a spliced TCP socket is handled inline through Pipeline. Returns {:ok, nil} - replies are sent asynchronously by workers or the fast path.