wsheader

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: 12 Imported by: 0

Documentation

Overview

Package wsheader encodes and validates WireHop WebSocket admission headers.

Index

Constants

View Source
const (
	// Subprotocol is the WebSocket subprotocol for wire protocol version one.
	Subprotocol = "wirehop.v1"
	// MaxPathSize leaves room for bounded admission fields within the direct server's request-header budget.
	MaxPathSize = 8 * 1024
)

Variables

View Source
var (
	// ErrInvalid indicates missing, duplicated, malformed, or inconsistent admission headers.
	ErrInvalid = errors.New("invalid WebSocket admission headers")
)

Functions

func Headers

func Headers(request Create) (http.Header, error)

Headers returns canonical HTTP headers for request.

func JoinHeaders

func JoinHeaders(request Join) (http.Header, error)

JoinHeaders returns canonical HTTP headers for an already signed join.

func ParseRejection

func ParseRejection(headers http.Header) (protocol.ServerHello, error)

ParseRejection decodes one canonical rejection from headers.

func SetRejection

func SetRejection(headers http.Header, rejection protocol.ServerHello) error

SetRejection encodes rejection into headers.

func SignJoin

func SignJoin(request *Join, secret protocol.SessionSecret) error

SignJoin validates request and authenticates its canonical encoding.

func ValidateBearerToken

func ValidateBearerToken(token string) error

ValidateBearerToken verifies the RFC 6750 b64token character grammar used by session creation.

func VerifyJoin

func VerifyJoin(request Join, secret protocol.SessionSecret) error

VerifyJoin verifies request against the ephemeral session secret.

Types

type Create

type Create struct {
	Token           string
	Target          target.Endpoint
	LaneID          protocol.LaneID
	Generation      uint64
	PathGroupID     protocol.PathGroupID
	Nonce           protocol.Nonce
	UnixSeconds     int64
	MonotonicMicros uint64
}

Create is one WebSocket session-creation request.

func ParseCreate

func ParseCreate(request *http.Request) (Create, error)

ParseCreate parses the required creation headers from request.

func (Create) Validate

func (r Create) Validate() error

Validate verifies canonical request fields and an HTTP-safe bearer token.

type Join

type Join struct {
	Method          string
	Path            string
	SessionID       protocol.SessionID
	LaneID          protocol.LaneID
	Generation      uint64
	PathGroupID     protocol.PathGroupID
	Nonce           protocol.Nonce
	UnixSeconds     int64
	MonotonicMicros uint64
	AuthTag         protocol.AuthTag
}

Join is one WebSocket lane join request.

func ParseJoin

func ParseJoin(request *http.Request) (Join, error)

ParseJoin parses the required signed join fields from request.

Jump to

Keyboard shortcuts

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