Documentation
¶
Overview ¶
Package turnpath owns session-scoped delegated TURN paths. It consumes account authority from the application without knowing how a provider issues secrets.
Index ¶
- Constants
- Variables
- func WatchTransport(parent context.Context, lease *Lease, sample func() Usage, stop func(error)) func()
- type Accounts
- type Admission
- type AuthorizedPath
- type Event
- type Inventory
- type Lease
- type LeaseConfig
- type Measurement
- type Profile
- type Receiver
- type ReceiverConfig
- type ReceiverPath
- type Sender
- func (s *Sender) Admit(ctx context.Context, path [16]byte, lane turncontrol.Lane, ...) *Admission
- func (s *Sender) Handle(ctx context.Context, body []byte) error
- func (s *Sender) Lookup(path [16]byte) (*AuthorizedPath, bool, error)
- func (s *Sender) Recover(path [16]byte, reason turncontrol.RecoveryReason)
- func (s *Sender) Run(ctx context.Context)
- type SenderConfig
- type Subject
- type Usage
Constants ¶
const ( TransportConnectBudget = 12 * time.Second TransportEvaluationBudget = 20 * time.Second TransportEvaluationBytes = 8 << 20 TransportEvaluationDelay = 10 * time.Second TransportEvaluationCooldown = 30 * time.Second TransportReevaluationInterval = 2 * time.Minute TransportImprovementRatio = 1.25 TransportImprovementHold = 2 * time.Second )
const ( MaximumActiveServices = 2 MaximumReplacementPaths = 1 ServiceCooldown = 30 * time.Second ReplacementBudget = 90 * time.Second MaintenanceInterval = time.Second MaximumRetiredPaths = 128 AdvertisementInterval = 5 * time.Second ControlWriteBudget = 5 * time.Second )
const MaximumRecoveryReplacements = 2
Variables ¶
var ( ErrSuperseded = errors.New("TURN configuration superseded") ErrBudget = errors.New("TURN account local usage budget exhausted") )
Functions ¶
func WatchTransport ¶
func WatchTransport(parent context.Context, lease *Lease, sample func() Usage, stop func(error)) func()
WatchTransport charges actual socket deltas, including allocation traffic and retransmission. The owner joins this watcher after closing transport, before releasing the account lease, so the final sample includes shutdown traffic.
Types ¶
type Admission ¶
type Admission struct {
// contains filtered or unexported fields
}
Admission is the revocable authority of one authenticated lane incarnation. A grant can outlive several attempts; closing an old admission cannot revoke the next attempt's authority.
type AuthorizedPath ¶
type AuthorizedPath struct {
*Lease
ReplacesPeerPathID [16]byte
// contains filtered or unexported fields
}
AuthorizedPath binds delegated credentials to their authenticated predecessor.
func (*AuthorizedPath) Relay ¶
func (p *AuthorizedPath) Relay() iceconfig.Relay
type Inventory ¶
Inventory is one atomic configuration view. Changed closes when a newer view is available, so a sender cannot miss an update between reading and waiting. Its revision orders views; Profile.Revision determines issuance validity.
type Lease ¶
type Lease struct {
// contains filtered or unexported fields
}
Lease binds delegated credentials to local account capacity. Releasing it stops local authority; provider-confirmed revocation is an account observation.
func NewLease ¶
func NewLease(config LeaseConfig) *Lease
type LeaseConfig ¶
type Measurement ¶
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
func NewReceiver ¶
func NewReceiver(config ReceiverConfig) *Receiver
func (*Receiver) Recover ¶
func (r *Receiver) Recover(path [16]byte, reason turncontrol.RecoveryReason)
type ReceiverConfig ¶
type ReceiverConfig struct {
SessionID [16]byte
Send func(context.Context, []byte) error
Open func(context.Context, turncontrol.Grant, iceconfig.Connection) (ReceiverPath, error)
Admitted func(turncontrol.Grant, ReceiverPath)
Observe func(Event)
Now func() time.Time
Tick <-chan time.Time
Measure func(turncontrol.Lane) Measurement
NetworkGeneration func() [16]byte
}
type ReceiverPath ¶
type ReceiverPath interface {
Lane() (turncontrol.Lane, bool)
Done() <-chan struct{}
Close() error
}
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
func NewSender ¶
func NewSender(config SenderConfig) *Sender
func (*Sender) Lookup ¶
func (s *Sender) Lookup(path [16]byte) (*AuthorizedPath, bool, error)
Lookup is the sender's authority check before constructing a native attempt. A retired grant cannot fall through to ordinary direct-path preparation.
func (*Sender) Recover ¶
func (s *Sender) Recover(path [16]byte, reason turncontrol.RecoveryReason)
Recover is safe in transport callbacks and never waits on signaling or issuance. Maintenance consumes the durable request even if the wake is full.