pionpeer

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 Imports: 18 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 (
	HostSTUNDiscovered = "stun_host_port_discovered"
	GatheringComplete  = "gathering_complete"
	ProviderClosed     = "provider_closed"
)

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
	SocketLease         *socketauthority.Lease
	MappedEndpoints     []MappedEndpoint
	Observe             func(Event)
	// OnClosed runs once synchronously inside Close after physical teardown and
	// socket lease release, before Close returns to any concurrent caller. It
	// must be lightweight, non-blocking, and must not reenter Connection.Close.
	OnClosed func()
	// contains filtered or unexported fields
}

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 NewTURNPeerConnection added in v0.1.6

func NewTURNPeerConnection(ctx context.Context, base pion.Configuration, relay iceconfig.TURNRelay, identity AttemptConfig) (*Connection, error)

TURN uses the system route to the allocation server. Direct interface filters, gateway maps and leased host sockets do not apply to this transport. Dialing and DNS resolution stay bound to ctx and to Connection.Close so an unresponsive TCP/TLS TURN address cannot hold teardown until the OS timeout.

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 or passive TCP syntax alone can never grant mapped-candidate provenance.

func (*Connection) LocalDescription added in v0.1.6

func (c *Connection) LocalDescription() *pion.SessionDescription

Supplemental mapped candidates travel by trickle, outside Pion's local SDP.

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)

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
}

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.

Jump to

Keyboard shortcuts

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