relay

package
v0.0.0-...-c48c3e2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DataChannelLabel is the pre-negotiated (id=0) DataChannel label WA Web uses.
	DataChannelLabel = "pre-negotiated"
	// SctpPort is the SCTP-over-DTLS WebRTC port (a WebRTC convention; pion's
	// sctp.Client negotiates over the DTLS conn and does not take it as config).
	SctpPort = 5000
)

Variables

This section is empty.

Functions

func UnwrapGroupForwardingPacket

func UnwrapGroupForwardingPacket(data []byte) (payload []byte, wrapped, valid bool)

UnwrapGroupForwardingPacket removes a captured multi-participant relay forwarding header. Non-forwarded packets are returned unchanged.

Types

type CallTransportError

type CallTransportError struct {
	Op  string // "connect", "send", or "recv"
	Err error
}

CallTransportError categorizes a relay-transport failure so a consumer can branch: Connect is fatal (the call can't reach the relay); Send/Recv are recoverable on an established channel.

func (*CallTransportError) Error

func (e *CallTransportError) Error() string

func (*CallTransportError) Unwrap

func (e *CallTransportError) Unwrap() error

type Option

type Option func(*config)

Option configures optional, non-behavioral aspects of the relay channel — currently the diagnostic logger. The zero configuration logs nothing.

func WithLogger

func WithLogger(l zerolog.Logger) Option

WithLogger sets the zerolog logger for debug/trace diagnostics. The library never configures logging itself; without this option the channel is silent at zero cost. Pass the logger from a context, e.g. WithLogger(*zerolog.Ctx(ctx)).

type RelayMediaChannel

type RelayMediaChannel struct {
	// contains filtered or unexported fields
}

RelayMediaChannel is an open relay media channel; STUN/RTP/RTCP travel as binary DataChannel messages. It owns the whole stack so Close tears it down cleanly (the reference relies on Rust Drop; Go needs explicit cleanup).

func ConnectRelayMedia

func ConnectRelayMedia(relayAddr *net.UDPAddr, opts ...Option) (*RelayMediaChannel, error)

ConnectRelayMedia connects the full media stack (UDP→DTLS→SCTP→DataChannel) to one relay endpoint. Self-signed cert; server-cert verification skipped (media auth is HBH SRTP, not DTLS). No vector — validated only against a live relay.

func (*RelayMediaChannel) Close

func (c *RelayMediaChannel) Close() error

Close tears down the media stack in reverse order of construction.

func (*RelayMediaChannel) Recv

func (c *RelayMediaChannel) Recv(buf []byte) (int, error)

Recv reads one DataChannel message into buf, returning its length.

func (*RelayMediaChannel) Send

func (c *RelayMediaChannel) Send(data []byte) (int, error)

Send writes one media/STUN packet as a binary DataChannel message.

type RelayPacketKind

type RelayPacketKind int

RelayPacketKind classifies a packet seen on the relay channel by its first byte.

const (
	RelayPacketStun RelayPacketKind = iota
	RelayPacketRtcp
	RelayPacketRtp
	RelayPacketOther
)

func ClassifyRelayPacket

func ClassifyRelayPacket(data []byte, log ...zerolog.Logger) RelayPacketKind

ClassifyRelayPacket demuxes STUN from RTP/RTCP using the RTP version and payload type ranges. WhatsApp video RTCP sets a profile bit, so its first byte can be 0x91.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址