Documentation
¶
Overview ¶
Package socketauthority owns bounded, independent per-path UDP endpoints. A lease survives a serialized fresh ICE attempt, while no endpoint is shared between peer paths whose remote tuples can otherwise collide in Pion's mux.
Index ¶
- Constants
- Variables
- type Authority
- func (a *Authority) Acquire(session [16]byte, generation uint64, path [16]byte, addresses []netip.Addr) (*Lease, error)
- func (a *Authority) Close() error
- func (a *Authority) Request(session [16]byte, generation uint64, path [16]byte, addresses []netip.Addr) (*Request, error)
- func (a *Authority) Retire(generation uint64)
- type CapacityError
- type Config
- type Event
- type EventKind
- type Lease
- func (l *Lease) Claim() (*Mux, func(), error)
- func (l *Lease) Close() error
- func (l *Lease) Endpoints() []netip.AddrPort
- func (l *Lease) GenerationID() uint64
- func (l *Lease) PathID() [16]byte
- func (l *Lease) PrepareTCP(includeIPv6 bool) error
- func (l *Lease) Retain() (*Lease, error)
- func (l *Lease) SessionID() [16]byte
- func (l *Lease) StartIdle(ctx context.Context, servers []netip.AddrPort, deadline time.Time) error
- func (l *Lease) TCP() *TCPMux
- func (l *Lease) TCPEndpoints() []netip.AddrPort
- type ListenPacket
- type Mux
- func (m *Mux) Close() error
- func (m *Mux) GetConn(ufrag string, addr net.Addr) (net.PacketConn, error)
- func (m *Mux) GetConnForURL(ufrag, url string, addr net.Addr) (net.PacketConn, error)
- func (m *Mux) GetListenAddresses() []net.Addr
- func (m *Mux) GetRelayedAddr(net.Addr, time.Duration) (*net.Addr, error)
- func (m *Mux) GetXORMappedAddr(server net.Addr, deadline time.Duration) (*stun.XORMappedAddress, error)
- func (m *Mux) GetXORMappedAddrForLocal(ctx context.Context, server, local net.Addr, deadline time.Duration) (*stun.XORMappedAddress, error)
- func (m *Mux) RemoveConnByUfrag(ufrag string)
- type Request
- type Reservation
- type TCPMux
- func (m *TCPMux) Close() error
- func (m *TCPMux) GetAllConns(ufrag string, isIPv6 bool, local net.IP) ([]net.PacketConn, error)
- func (m *TCPMux) GetConnByUfrag(ufrag string, isIPv6 bool, local net.IP) (net.PacketConn, error)
- func (m *TCPMux) GetConnForEndpoint(ufrag string, local netip.AddrPort) (net.PacketConn, error)
- func (m *TCPMux) RemoveConnByUfrag(ufrag string)
Constants ¶
const ( DefaultCapacity = 64 MaxAddressesPerPath = 16 DefaultIdleInterval = 15 * time.Second DefaultRefreshTimeout = 500 * time.Millisecond )
const MaxIdleHold = 2 * time.Minute
const MaxIdleServers = 2
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Authority ¶
type Authority struct {
// contains filtered or unexported fields
}
Authority owns physical sockets; leases own only demand references.
func (*Authority) Acquire ¶
func (a *Authority) Acquire(session [16]byte, generation uint64, path [16]byte, addresses []netip.Addr) (*Lease, error)
Acquire freezes addresses for this generation/path. Callers must allocate a newer generation for address/route changes; an existing snapshot is never edited.
type CapacityError ¶
type CapacityError struct {
Used, Reserved, Requested, Limit int
}
CapacityError preserves the accounting decision across admission and tracing.
func (*CapacityError) Error ¶
func (e *CapacityError) Error() string
func (*CapacityError) Unwrap ¶
func (*CapacityError) Unwrap() error
type Event ¶
type Event struct {
ProtocolSessionID [16]byte
PeerPathID [16]byte
NetworkGenerationID uint64
Kind EventKind
At time.Time
Duration time.Duration
Local, Server netip.AddrPort
Result string
}
Socket work belongs to a path, not an ICE attempt that may already have ended.
type Lease ¶
type Lease struct {
// contains filtered or unexported fields
}
Lease is a separately releasable demand reference. Retain never revives a released lease or a retired network generation.
func (*Lease) Claim ¶
Claim transfers exclusive keepalive ownership to one ICE agent. The returned release must run after PeerConnection.Close completes, before replacement.
func (*Lease) GenerationID ¶
func (*Lease) PrepareTCP ¶
PrepareTCP is called only after a proven peer capability profile is selected. It is demand-owned and bounded by the same process socket capacity as UDP.
func (*Lease) StartIdle ¶
StartIdle holds NAT discovery mappings only until the caller's already budgeted fresh attempt deadline. It does not retain a demand reference and therefore cannot keep an otherwise unused endpoint or generation alive. Repeated handoffs cancel and join the previous heartbeat before replacement.
func (*Lease) TCPEndpoints ¶
type ListenPacket ¶
type ListenPacket func(network, address string) (net.PacketConn, error)
ListenPacket is injected so allocation and failure cleanup are testable.
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux routes each local interface/family to its own physical endpoint. It is immutable once published; only Authority closes it.
func (*Mux) GetConnForURL ¶
func (*Mux) GetListenAddresses ¶
func (*Mux) GetRelayedAddr ¶
func (*Mux) GetXORMappedAddr ¶
func (*Mux) GetXORMappedAddrForLocal ¶
func (*Mux) RemoveConnByUfrag ¶
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request is immutable and can be retried by the single process admission queue.
func (*Request) Changes ¶
func (r *Request) Changes() <-chan struct{}
Changes must be sampled before Reserve so a concurrent release cannot be lost.
func (*Request) Reserve ¶
func (r *Request) Reserve() (*Reservation, error)
Reserve performs no network I/O. Optional TCP listeners share this ledger but cannot consume capacity already promised to another path's mandatory UDP set.
func (*Request) ReserveOptional ¶
func (r *Request) ReserveOptional() (*Reservation, error)
ReserveOptional leaves a complete mandatory socket opportunity for a new receiver. The reserve uses the frozen address cost, not a guessed path count.
type Reservation ¶
type Reservation struct {
// contains filtered or unexported fields
}
Reservation owns either a future allocation or a retained existing lease. Activate transfers ownership once; abandonment returns only this reservation.
func (*Reservation) Activate ¶
func (r *Reservation) Activate() (*Lease, error)
func (*Reservation) Close ¶
func (r *Reservation) Close()
type TCPMux ¶
type TCPMux struct {
// contains filtered or unexported fields
}
TCPMux preserves exact local interface/listener affinity.
func (*TCPMux) GetAllConns ¶
func (*TCPMux) GetConnByUfrag ¶
func (*TCPMux) GetConnForEndpoint ¶
GetConnForEndpoint prevents a mapped port from borrowing another listener.