server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package server implements WireHop server admission and session ownership.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidConfig indicates missing authentication, policy, timing, or queue configuration.
	ErrInvalidConfig = errors.New("invalid server configuration")
	// ErrSessionLimit indicates that the server has reached its bounded session capacity.
	ErrSessionLimit = errors.New("server session limit reached")
	// ErrSessionIDCollision indicates that generated session identity was already retained.
	ErrSessionIDCollision = errors.New("generated session ID collision")
)
View Source
var (
	// ErrLaneLimit indicates that a session has reached its stable lane identifier limit.
	ErrLaneLimit = errors.New("session lane limit reached")
	// ErrSessionClosed indicates admission against a closing or expired session.
	ErrSessionClosed = errors.New("session closed")
	// ErrPathGroupMismatch indicates a stable lane identity changed its correlation group.
	ErrPathGroupMismatch = errors.New("lane path group changed")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Token                []byte
	Targets              policy.TargetSet
	Clock                relay.Clock
	WallClock            func() time.Time
	Logger               *slog.Logger
	Resolver             target.Resolver
	AuthenticationSkew   time.Duration
	HandshakeTimeout     time.Duration
	ReplayEntries        int
	JoinNonceEntries     int
	MaxSessions          int
	MaxLanesPerSession   int
	MaxPendingAdmissions int
	ReconnectGrace       time.Duration
	IngressLimits        packetqueue.Limits
	LaneLimits           packetqueue.Limits
	RetentionLimits      retention.Limits
	Deadlines            relay.DeadlinePolicy
	DeduplicationWindow  int
}

Config defines carrier admission and per-session resource limits.

type Server

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

Server accepts authenticated carrier lanes and owns their relay sessions.

func New

func New(config Config) (*Server, error)

New validates config and returns a server.

func (*Server) Serve

func (s *Server) Serve(parent context.Context, listener net.Listener) error

Serve accepts binary stream carrier connections until context cancellation or listener failure.

func (*Server) Snapshot

func (s *Server) Snapshot() Snapshot

Snapshot returns bounded aggregate session and lane counts without credential material.

func (*Server) WebSocketConnContext

func (s *Server) WebSocketConnContext(parent context.Context, connection net.Conn) context.Context

WebSocketConnContext attaches a pre-header admission reservation to its HTTP connection context.

func (*Server) WebSocketHandler

func (s *Server) WebSocketHandler(ctx context.Context) http.Handler

WebSocketHandler returns an HTTP handler for authenticated WebSocket creator lanes.

func (*Server) WebSocketListener

func (s *Server) WebSocketListener(listener net.Listener) net.Listener

WebSocketListener bounds TLS handshakes and HTTP header parsing with the shared admission limit. For WSS, apply this wrapper before the TLS listener so http.Server receives the resulting TLS connection directly.

type Snapshot

type Snapshot struct {
	Sessions          int
	AttachedLanes     int
	Detached          int
	CreatingSessions  int
	PendingAdmissions int
	RetainedPackets   int
	RetainedBytes     int
}

Snapshot is a point-in-time view of bounded server resources.

Jump to

Keyboard shortcuts

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