transport

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
	After(time.Duration) <-chan time.Time
	AfterFunc(time.Duration, func()) Timer
}

type ControlMessage

type ControlMessage struct {
	Type       ControlType `json:"type"`
	Candidates []string    `json:"candidates,omitempty"`
}

type ControlType

type ControlType string
const (
	ControlCandidates  ControlType = "candidates"
	ControlCallMeMaybe ControlType = "call-me-maybe"
)

type DirectBatchConn

type DirectBatchConn interface {
	ReadBatch([]ipv6.Message, int) (int, error)
	SetReadDeadline(time.Time) error
}

type DiscoveryKey added in v0.10.0

type DiscoveryKey [32]byte

func (DiscoveryKey) IsZero added in v0.10.0

func (k DiscoveryKey) IsZero() bool

type Manager

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

func NewManager

func NewManager(cfg ManagerConfig) *Manager

func (*Manager) CurrentPeerRecvQueueDepth added in v0.15.0

func (m *Manager) CurrentPeerRecvQueueDepth() int

func (*Manager) DirectAddr

func (m *Manager) DirectAddr() (net.Addr, bool)

func (*Manager) DirectPacketConn added in v0.15.0

func (m *Manager) DirectPacketConn() (net.PacketConn, net.Addr, bool)

func (*Manager) DirectPath

func (m *Manager) DirectPath() (string, bool)

func (*Manager) DroppedPeerDatagrams

func (m *Manager) DroppedPeerDatagrams() uint64

func (*Manager) HandleDirectPacket

func (m *Manager) HandleDirectPacket(conn net.PacketConn, addr net.Addr, payload []byte) bool

func (*Manager) MarkDirectBroken

func (m *Manager) MarkDirectBroken() error

func (*Manager) MaxPeerRecvQueueDepth

func (m *Manager) MaxPeerRecvQueueDepth() int

func (*Manager) NoteDirectActivity

func (m *Manager) NoteDirectActivity(addr net.Addr)

func (*Manager) PathEvents added in v0.16.3

func (m *Manager) PathEvents(ctx context.Context) <-chan PathEvent

func (*Manager) PathSnapshot added in v0.16.3

func (m *Manager) PathSnapshot() PathSnapshot

func (*Manager) PathSnapshots added in v0.16.3

func (m *Manager) PathSnapshots(ctx context.Context) <-chan PathSnapshot

func (*Manager) PathState

func (m *Manager) PathState() Path

func (*Manager) PeerDatagramConn

func (m *Manager) PeerDatagramConn(ctx context.Context) PeerDatagramConn

func (*Manager) RejectedDirectDatagrams

func (m *Manager) RejectedDirectDatagrams() uint64

func (*Manager) SeedRemoteCandidates

func (m *Manager) SeedRemoteCandidates(ctx context.Context, candidates []net.Addr)

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

func (*Manager) StopDirect

func (m *Manager) StopDirect()

func (*Manager) StopDirectReads

func (m *Manager) StopDirectReads()

func (*Manager) Updates

func (m *Manager) Updates(ctx context.Context) <-chan Update

func (*Manager) Wait

func (m *Manager) Wait()

type ManagerConfig

type ManagerConfig struct {
	RelayConn               net.PacketConn
	RelaySend               func(context.Context, []byte) error
	ReceiveRelay            func(context.Context) ([]byte, error)
	RelayAddr               net.Addr
	DirectConn              net.PacketConn
	DirectBatchConn         DirectBatchConn
	DisableDirectReads      bool
	HandleSTUNPacket        func([]byte, net.Addr)
	CandidateSource         func(context.Context) []net.Addr
	Portmap                 Portmap
	SendControl             func(context.Context, ControlMessage) error
	ReceiveControl          func(context.Context) (ControlMessage, error)
	Clock                   Clock
	DiscoveryInterval       time.Duration
	EndpointRefreshInterval time.Duration
	DirectStaleTimeout      time.Duration
	DiscoveryKey            DiscoveryKey
}

type Path

type Path int

Path describes the currently selected transport path.

const (
	PathUnknown Path = iota
	PathRelay
	PathDirect
)

type PathCandidateSnapshot added in v0.16.3

type PathCandidateSnapshot struct {
	Addr         net.Addr
	RTT          time.Duration
	Selected     bool
	ProbePending bool
	ProbeSentAt  time.Time
}

type PathEvent added in v0.16.3

type PathEvent struct {
	At           time.Time
	Type         PathEventType
	Reason       PathEventReason
	Source       PathEventSource
	Path         Path
	PreviousPath Path
	SelectedAddr net.Addr
	PreviousAddr net.Addr
	TargetAddr   net.Addr
	RTT          time.Duration
	Snapshot     PathSnapshot
}

type PathEventReason added in v0.16.3

type PathEventReason string
const (
	PathEventReasonProbeAck         PathEventReason = "probe-ack"
	PathEventReasonDirectBroken     PathEventReason = "direct-broken"
	PathEventReasonDirectStale      PathEventReason = "direct-stale"
	PathEventReasonCandidateLost    PathEventReason = "candidate-lost"
	PathEventReasonStopDirect       PathEventReason = "stop-direct"
	PathEventReasonProbeWriteFailed PathEventReason = "probe-write-failed"
)

type PathEventSource added in v0.16.3

type PathEventSource string
const (
	PathEventSourceDirectProbe   PathEventSource = "direct-probe"
	PathEventSourceDiscovery     PathEventSource = "discovery"
	PathEventSourceManual        PathEventSource = "manual"
	PathEventSourceRemoteControl PathEventSource = "remote-control"
	PathEventSourceSeed          PathEventSource = "seed"
	PathEventSourceStaleCheck    PathEventSource = "stale-check"
	PathEventSourceStopDirect    PathEventSource = "stop-direct"
)

type PathEventType added in v0.16.3

type PathEventType string
const (
	PathEventCandidatesChanged PathEventType = "candidates-changed"
	PathEventProbeSent         PathEventType = "probe-sent"
	PathEventProbeFailed       PathEventType = "probe-failed"
	PathEventProbeSucceeded    PathEventType = "probe-succeeded"
	PathEventSelected          PathEventType = "selected"
	PathEventFallback          PathEventType = "fallback"
	PathEventLagged            PathEventType = "lagged"
)

type PathSnapshot added in v0.16.3

type PathSnapshot struct {
	At           time.Time
	Path         Path
	SelectedAddr net.Addr
	SelectedRTT  time.Duration
	Candidates   []PathCandidateSnapshot
	Upgrades     int
	Fallbacks    int
}

type PeerDatagramConn

type PeerDatagramConn interface {
	SendDatagram([]byte) error
	RecvDatagram(context.Context) ([]byte, net.Addr, error)
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	ReleaseDatagram([]byte)
	Close() error
}

type Portmap

type Portmap interface {
	Refresh(time.Time) bool
	SnapshotAddrs() []net.Addr
}

type Timer

type Timer interface {
	Stop() bool
}

type Update

type Update struct {
	Path Path
}

Jump to

Keyboard shortcuts

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