Documentation
¶
Overview ¶
Package socketauthority owns bounded, independent per-path UDP endpoints and optional passive TCP listeners under separate capacity ledgers. 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 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() error
- func (l *Lease) Retain() (*Lease, error)
- func (l *Lease) SessionID() [16]byte
- func (l *Lease) TCP() *TCPMux
- func (l *Lease) TCPEndpoints() []netip.AddrPort
- type ListenPacket
- type Mux
- func (m *Mux) Close() error
- func (m *Mux) DiscoverXORMappedAddr(ctx context.Context, local netip.AddrPort, server *net.UDPAddr, ...) (netip.AddrPort, error)
- func (m *Mux) GetConn(ufrag string, addr net.Addr) (net.PacketConn, error)
- func (m *Mux) GetListenAddresses() []net.Addr
- func (m *Mux) RemoveConnByUfrag(ufrag string)
- type Request
- type Reservation
- type TCPMux
Constants ¶
const ( // DefaultUDPCapacity and DefaultTCPCapacity each accommodate four full // MaxAddressesPerPath paths (three active direct paths plus one reserved // essential opportunity) under independent ledgers so optional passive TCP // listeners can never starve mandatory UDP paths. DefaultUDPCapacity = 64 DefaultTCPCapacity = 64 MaxAddressesPerPath = 16 )
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 ¶
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 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 ICE ownership for this path lease. The returned release must run after PeerConnection.Close completes, before replacement.
func (*Lease) GenerationID ¶
func (*Lease) PrepareTCP ¶
PrepareTCP allocates optional passive TCP listeners for all lease addresses. Listeners draw from an independent TCP capacity pool so they can never starve mandatory UDP paths; optional paths additionally leave room for one essential path's TCP listeners.
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) DiscoverXORMappedAddr ¶ added in v0.1.6
func (m *Mux) DiscoverXORMappedAddr(ctx context.Context, local netip.AddrPort, server *net.UDPAddr, timeout time.Duration) (netip.AddrPort, error)
The socket survives across attempts. Its current owner must cancel and drain outstanding discovery before releasing the claim to its successor.
func (*Mux) GetListenAddresses ¶
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 and accounts exclusively against the mandatory UDP ledger. Optional passive TCP listeners use an independent capacity pool.
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.