pionpeer

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0 Imports: 23 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pionpeer adapts one Pion PeerConnection to an immutable connectivity resource snapshot. Retry, mapping and network-generation ownership stay above it.

Index

Constants

View Source
const (
	TURNDialTimeout = 10 * time.Second
	// TURN deallocation is sent without waiting for a response. This grace
	// bounds stalled writes/gathering without imposing a normal close delay.
	TURNCloseGrace = 250 * time.Millisecond
)
View Source
const InitialCheckingTimeout = 39500 * time.Millisecond

InitialCheckingTimeout follows RFC 8863's default transaction window. It deliberately does not extend failure detection after a pair was connected.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttemptConfig

type AttemptConfig struct {
	ProtocolSessionID      [16]byte
	PeerPathID             [16]byte
	AttemptID              [16]byte
	NetworkGenerationID    uint64
	ICEProfileID           string
	ICE                    iceconfig.Connection
	TURN                   *TURNConfig
	OnTURNRecovery         func(turncontrol.RecoveryReason)
	InitialCheckingTimeout time.Duration
	TCPProfile             TCPProfile
	SocketLease            *socketauthority.Lease
	MappedEndpoints        []MappedEndpoint
	Observe                func(Event)
}

AttemptConfig is a value snapshot; referenced lists are copied before creation.

type CandidateFacts

type CandidateFacts struct {
	Priority uint32
	TCPType  string
	Type     string
	Protocol string
	Address  string
	Port     uint16
	Family   string
	Origin   string
}

type Connection

type Connection struct {
	*pion.PeerConnection
	// contains filtered or unexported fields
}

func NewPeerConnection

func NewPeerConnection(configuration pion.Configuration, request AttemptConfig) (*Connection, error)

NewPeerConnection acquires an exclusive attempt reference. The caller's path lease must remain held if a future fresh attempt is already budgeted.

func (*Connection) Close

func (c *Connection) Close() error

func (*Connection) IsMappedCandidate

func (c *Connection) IsMappedCandidate(raw string) bool

IsMappedCandidate matches a candidate to the trusted immutable lease snapshot; srflx syntax alone can never grant mapped-candidate provenance.

func (*Connection) OnConnectionStateChange

func (c *Connection) OnConnectionStateChange(callback func(pion.PeerConnectionState))

func (*Connection) OnICECandidate

func (c *Connection) OnICECandidate(callback func(*pion.ICECandidate))

func (*Connection) OnICEConnectionStateChange

func (c *Connection) OnICEConnectionStateChange(callback func(pion.ICEConnectionState))

These wrappers preserve provider observations when consumers install their own callbacks. A PC state is recorded as itself, never as an invented DTLS fact.

func (*Connection) SelectedPair

func (c *Connection) SelectedPair() (PairFacts, bool)

func (*Connection) TURNResources

func (c *Connection) TURNResources() (TURNResourceSnapshot, bool)

type Diagnostic

type Diagnostic struct {
	Scope    string
	Severity string
	Message  string
}

Diagnostic keeps provider log text separate from transport state transitions.

type Event

type Event struct {
	ProtocolSessionID   [16]byte
	PeerPathID          [16]byte
	AttemptID           [16]byte
	NetworkGenerationID uint64
	ICEProfileID        string
	Milestone           string
	State               string
	Diagnostic          *Diagnostic
	At                  time.Time
	Candidate           *CandidateFacts
	Pair                *PairFacts
	TURN                *TURNResourceSnapshot
	TURNService         *iceconfig.Identity
	TURNCleanup         connectionpath.CleanupOutcome
	TURNBinding         *turn.BindingEvent
	TURNRoute           *turnroute.Event
}

type MappedEndpoint

type MappedEndpoint struct {
	Local    netip.AddrPort
	External netip.AddrPort
	Protocol string
}

type PairFacts

type PairFacts struct {
	LocalType     string
	RemoteType    string
	Protocol      string
	LocalAddress  string
	RemoteAddress string
	LocalPort     uint16
	RemotePort    uint16
	RoundTripTime time.Duration
}

PairFacts reports the actual selected pair; caller still owns authenticated lane admission and must not infer directness from gathered candidates.

type TCPCapability

type TCPCapability struct {
	IPv4, IPv6  bool
	PassiveOnly bool
}

func Capabilities

func Capabilities(profile TCPProfile) TCPCapability

type TCPProfile

type TCPProfile string

TCPProfile names exact implementation/platform combinations backed by local selected-pair and authenticated-payload evidence. It is sent only through authenticated session controls; absent or unknown profiles remain UDP-only.

const (
	TCPNativeWindows   TCPProfile = "pion-4.2.16-ice-4.2.7-windows"
	TCPChromiumWindows TCPProfile = "chromium-151.0.7922.34-windows"
)

func LocalTCPProfile

func LocalTCPProfile() TCPProfile

type TURNConfig

type TURNConfig struct {
	Plan        *turnroute.Plan
	Reservation TURNReservation
}

TURNConfig keeps the admitted plan and its capacity together through handoff.

type TURNReservation

type TURNReservation interface {
	turnroute.Capacity
	Claim([16]byte, [16]byte, iceconfig.Identity) error
	SocketLimit() int
	Close()
}

TURNReservation is the capability an admitted attempt needs. The provider cannot change queue policy, mint capacity or inspect other paths' reservations.

type TURNResourceSnapshot

type TURNResourceSnapshot struct {
	ActiveSockets     int
	OpenedSockets     uint64
	TransportSent     uint64
	TransportReceived uint64
}

Transport counters include TURN framing, TLS and protocol retries visible to the process. They are not provider billing or kernel TCP retransmission counts.

Jump to

Keyboard shortcuts

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