sendersession

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, AGPL-3.0 Imports: 22 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 sendersession owns sharing-side session admission, catalog and content services, and orderly shutdown.

Index

Constants

View Source
const DefaultTerminalCleanupTimeout = 15 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type CatalogFactory

type CatalogFactory interface {
	NewSenderCatalogService() (*catalogflow.AddressedSenderService, error)
}

type CatalogFactoryFunc

type CatalogFactoryFunc func() (*catalogflow.AddressedSenderService, error)

func (CatalogFactoryFunc) NewSenderCatalogService

func (function CatalogFactoryFunc) NewSenderCatalogService() (*catalogflow.AddressedSenderService, error)

type ChannelAdmission

type ChannelAdmission struct {
	Kind    ChannelKind
	Session *Runtime
	Lane    session.LaneIdentity
}

type ChannelKind

type ChannelKind uint8
const (
	ChannelNewProtocolSession ChannelKind = iota + 1
	ChannelAttachedLane
)

type ContentFactory

type ContentFactory interface {
	NewSenderContentService(protocolsession.ProtocolSessionID) (*contentflow.SenderService, error)
}

type ContentFactoryFunc

func (ContentFactoryFunc) NewSenderContentService

func (function ContentFactoryFunc) NewSenderContentService(
	sessionID protocolsession.ProtocolSessionID,
) (*contentflow.SenderService, error)

type Factory

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

func NewFactory

func NewFactory(config FactoryConfig) (*Factory, error)

func (*Factory) Accept

func (factory *Factory) Accept(ctx context.Context, channel protocolsession.FrameChannel) (*Runtime, error)

func (*Factory) ActiveSessions

func (factory *Factory) ActiveSessions() int

func (*Factory) AdmitChannel

func (factory *Factory) AdmitChannel(
	ctx context.Context,
	channel protocolsession.FrameChannel,
) (ChannelAdmission, error)

AdmitChannel owns the first-frame dispatch boundary for opaque relay and P2P channels. A valid WS2A can only attach to a still-live ProtocolSession; every other candidate must prove a fresh WS2C transcript before it becomes a new session. Keeping this decision beside both authenticators prevents a transport owner from routing on untrusted session identities.

func (*Factory) Attach

func (factory *Factory) Attach(
	ctx context.Context,
	channel protocolsession.FrameChannel,
) (session.LaneIdentity, error)

Attach routes an untrusted WS2A only far enough to find its live ProtocolSession. Unknown/malformed candidates are closed without a response; all signed responses remain behind LaneRegistry's traffic-key proof.

func (*Factory) BeginStop

func (factory *Factory) BeginStop(message string) error

BeginStop closes factory admission synchronously, then runs every external callback and bounded join in the terminal worker. This makes it safe for connectivity cleanup to reenter BeginStop without deadlocking its caller.

func (*Factory) Stop

func (factory *Factory) Stop(ctx context.Context, message string) error

func (*Factory) String

func (factory *Factory) String() string

type FactoryConfig

type FactoryConfig struct {
	ShareInstance           catalog.ShareInstance
	SessionAuthKey          []byte
	SenderPrivateKey        ed25519.PrivateKey
	Catalog                 CatalogFactory
	Content                 ContentFactory
	Peers                   PeerHandlerFactory
	ReplayGuard             *protocolsession.ClientHelloReplayGuard
	Random                  io.Reader
	InitialLaneIDs          InitialLaneIDSource
	OperationLimits         protocolsession.OperationLimits
	RouterLimits            protocolsession.RouterLimits
	Now                     func() time.Time
	TerminalConnectivity    TerminalConnectivity
	TerminalTimeout         time.Duration
	TerminalSendObserver    sessionobs.SenderTerminalSendObserver
	SessionTerminalObserver sessionobs.SenderSessionTerminalObserver
	ProtocolObservations    observationstream.Producer[sessionobs.ProtocolObservation]
}

type InitialLaneIDSource

type InitialLaneIDSource interface {
	NextInitialLaneID() (uint32, error)
}

type InitialLaneIDSourceFunc

type InitialLaneIDSourceFunc func() (uint32, error)

func (InitialLaneIDSourceFunc) NextInitialLaneID

func (function InitialLaneIDSourceFunc) NextInitialLaneID() (uint32, error)

type PeerAdmissionControl

type PeerAdmissionControl interface {
	BeginAuthenticatedSettlement(protocolsession.OperationID, session.LaneIdentity) bool
}

PeerAdmissionControl owns the attempt's one-shot transition from admission-waiting to admission-settling. Core calls it only after WS2A has authenticated and before it consumes/rejects a grant or sends signed evidence.

type PeerAdmissionControlFunc

type PeerAdmissionControlFunc func(protocolsession.OperationID, session.LaneIdentity) bool

func (PeerAdmissionControlFunc) BeginAuthenticatedSettlement

func (function PeerAdmissionControlFunc) BeginAuthenticatedSettlement(
	operationID protocolsession.OperationID,
	lane session.LaneIdentity,
) bool

type PeerAdmissionDisposition

type PeerAdmissionDisposition uint8
const (
	PeerAdmissionSilentClose PeerAdmissionDisposition = iota + 1
	PeerAdmissionAccepted
	PeerAdmissionRejected
)

type PeerAdmissionResult

type PeerAdmissionResult struct {
	SettlementBegan  bool
	GrantOperationID protocolsession.OperationID
	Lane             session.LaneIdentity
	Disposition      PeerAdmissionDisposition
	Rejection        protocolsession.LaneRejection
	ResponseDelivery PeerResponseDelivery
	LaneAttachment   PeerLaneAttachment
}

PeerAdmissionResult is safe settlement evidence: it deliberately excludes WS2A/WS2B/WS2N bytes, nonces, proofs, traffic keys, and raw errors. The authenticated disposition remains authoritative when delivery or local attachment later fails.

type PeerHandler

PeerHandler owns provider policy, SDP/ICE interpretation, and physical PeerConnection lifetime outside core. Run must synchronously close all owned attempts before returning so ProtocolSession termination cannot leak peers.

type PeerHandlerFactory

type PeerHandlerFactory interface {
	protocolsession.OperationContinuationClassifier
	NewSenderPeerHandler(PeerSession) (PeerHandler, error)
}

PeerHandlerFactory creates one isolated signaling owner per ProtocolSession. Implementations must not start asynchronous work before Run.

type PeerHandlerFactoryFunc

type PeerHandlerFactoryFunc func(PeerSession) (PeerHandler, error)

func (PeerHandlerFactoryFunc) BeginOperationContinuation

func (PeerHandlerFactoryFunc) ClassifyUnboundOperationContinuation

func (function PeerHandlerFactoryFunc) ClassifyUnboundOperationContinuation(
	protocolsession.MessageKind,
	[]byte,
) (protocolsession.OperationContinuationScope, bool, error)

func (PeerHandlerFactoryFunc) NewSenderPeerHandler

func (function PeerHandlerFactoryFunc) NewSenderPeerHandler(
	peer PeerSession,
) (PeerHandler, error)

type PeerLaneAttachment

type PeerLaneAttachment uint8
const (
	PeerLaneAttachmentNotAttempted PeerLaneAttachment = iota + 1
	PeerLaneAttached
	PeerLaneAttachmentFailed
)

type PeerResponseDelivery

type PeerResponseDelivery uint8
const (
	PeerResponseNotAttempted PeerResponseDelivery = iota + 1
	PeerResponseDelivered
	PeerResponseDeliveryFailed
)

type PeerSession

type PeerSession interface {
	ShareInstance() catalog.ShareInstance
	ProtocolSessionID() protocolsession.ProtocolSessionID
	SendPeerControl(
		context.Context,
		protocolsession.MessageKind,
		protocolsession.OperationID,
		[]byte,
	) (protocolsession.OperationDisposition, error)
	FailPeerOperation(context.Context, protocolsession.OperationID, uint16, string) error
	AdmitPeerChannel(
		context.Context,
		protocolsession.FrameChannel,
		PeerAdmissionControl,
	) (PeerAdmissionResult, error)

	// Each control family owns an independent callback for the handler's Run
	// lifetime. Passing nil removes only that family's callback.
	SetPeerPathControlHandler(func(context.Context, []byte) error)
	SendPeerPathControl(context.Context, []byte) error
	SetTURNControlHandler(func(context.Context, []byte) error)
	SendTURNControl(context.Context, []byte) error
}

PeerSession is the transport-neutral authority granted to one connectivity-owned peer handler. Operation-scoped signaling is restricted to answers and candidates. Session-scoped path and TURN controls are required so wrappers cannot silently disable path maintenance or TURN delegation. AdmitPeerChannel admits only into the ProtocolSession that created this authority and consumes the candidate channel: core closes it exactly once on failure, while successful attachment transfers close authority to the lane.

type Runtime

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

func (*Runtime) AdmitPeerChannel

func (runtime *Runtime) AdmitPeerChannel(
	ctx context.Context,
	channel protocolsession.FrameChannel,
	control PeerAdmissionControl,
) (PeerAdmissionResult, error)

AdmitPeerChannel binds a connectivity-owned channel to this exact ProtocolSession before parsing its lane proof. A peer negotiation therefore cannot use the factory-wide untrusted route lookup to attach to a sibling receiver session.

func (*Runtime) AttachedLanes

func (runtime *Runtime) AttachedLanes() int

func (*Runtime) BeginClose

func (runtime *Runtime) BeginClose()

func (*Runtime) BeginStop

func (runtime *Runtime) BeginStop(ctx context.Context, message string) error

func (*Runtime) Close

func (runtime *Runtime) Close()

func (*Runtime) DetachLane

func (runtime *Runtime) DetachLane(identity session.LaneIdentity) bool

func (*Runtime) Done

func (runtime *Runtime) Done() <-chan struct{}

func (*Runtime) Err

func (runtime *Runtime) Err() error

Only lifecycle observations and explicit control-handler installation cross the role boundary. The core's lane registry and operation ownership stay private.

func (*Runtime) LaneDone

func (runtime *Runtime) LaneDone(identity session.LaneIdentity) (<-chan struct{}, bool)

LaneDone observes exact admitted ownership through registry release and transport cleanup. A remote close alone does not establish that boundary.

func (*Runtime) LaneIdentity

func (runtime *Runtime) LaneIdentity() (uint32, uint32)

func (*Runtime) LaneRegistry

func (runtime *Runtime) LaneRegistry() *protocolsession.LaneRegistry

func (*Runtime) Lifetime

func (runtime *Runtime) Lifetime() context.Context

func (*Runtime) ProtocolSessionID

func (runtime *Runtime) ProtocolSessionID() protocolsession.ProtocolSessionID

func (*Runtime) SetPeerPathControlHandler

func (runtime *Runtime) SetPeerPathControlHandler(handler func(context.Context, []byte) error)

func (*Runtime) SetTURNControlHandler

func (runtime *Runtime) SetTURNControlHandler(handler func(context.Context, []byte) error)

func (*Runtime) Stop

func (runtime *Runtime) Stop(ctx context.Context, message string) error

func (*Runtime) Stopping

func (runtime *Runtime) Stopping() bool

func (*Runtime) WaitClosed

func (runtime *Runtime) WaitClosed()

func (*Runtime) WaitStopped

func (runtime *Runtime) WaitStopped(ctx context.Context) error

type TerminalConnectivity

type TerminalConnectivity interface {
	// StopRecovery must return promptly after preventing new registration or
	// path-recovery work. Existing lanes remain available for terminal delivery
	// until Cleanup runs.
	StopRecovery()
	// Cleanup deregisters every relay route and closes connectivity-owned lanes.
	Cleanup(context.Context) error
}

TerminalConnectivity is defined at the session consumer boundary. Core never learns provider, TURN, relay-node, or path-cost details; it only coordinates monotonic share termination with the owner of those resources.

type TerminalConnectivityFuncs

type TerminalConnectivityFuncs struct {
	StopRecoveryFunc func()
	CleanupFunc      func(context.Context) error
}

func (TerminalConnectivityFuncs) Cleanup

func (functions TerminalConnectivityFuncs) Cleanup(ctx context.Context) error

func (TerminalConnectivityFuncs) StopRecovery

func (functions TerminalConnectivityFuncs) StopRecovery()

Jump to

Keyboard shortcuts

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