websocket

package
v0.212.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 27 Imported by: 0

README

Go+ WebSocket

goforge.dev/goplus/std/websocket implements RFC 6455 and RFC 7692 for Go+ and Go. The public message vocabulary is a closed Go+ sum type; framing hot paths remain allocation-free Go so both languages use the same wire code.

Server

conn, protocol, err := websocket.Upgrade(w, r, websocket.UpgradeOptions{
    Protocols:   []string{"assay.v1"},
    Compression: &websocket.CompressionOptions{},
})
if err != nil { return }
defer conn.Close()

message, err := conn.ReadMessage()
if err == nil {
    err = conn.WriteMessage(message)
}
_ = protocol

Upgrade does not impose an origin policy. Browser-facing endpoints should set CheckOrigin: websocket.SameOrigin; non-browser clients without an Origin header remain accepted by that helper.

Client

conn, response, err := websocket.Dial(ctx, "wss://example.test/socket",
    websocket.DialOptions{
        Protocols: []string{"assay.v1"},
        Compression: &websocket.CompressionOptions{
            ClientMaxWindowBits: 15,
        },
    })
if err != nil { return err }
defer conn.Close()
_ = response
return conn.WriteMessage(websocket.TextMessage{Payload: []byte("hello")})

For wss:// URLs, Dial uses RFC 9220 over HTTP/3 when origin capability is known, then RFC 8441 over HTTP/2, then the RFC 6455 HTTP/1.1 Upgrade. The same Upgrade handler accepts all three forms and Conn.HandshakeProtocol() exposes which path was selected when metrics need it. Cleartext ws:// remains RFC 6455 by default; use HTTP2: websocket.HTTP2Only for h2c prior knowledge.

Pass the regular Go+ HTTP transport as HTTP3Transport to share Alt-Svc learning and connection policy between ordinary requests and WebSockets:

transport := new(http.Transport)
_, _ = (&nethttp.Client{Transport: transport}).Get("https://example.test/")
conn, response, err := websocket.Dial(ctx, "wss://example.test/events",
    websocket.DialOptions{HTTP3Transport: transport})

HTTP3Only performs a direct QUIC attempt. Automatic mode does not blindly probe UDP for an origin with no learned capability, because a dropped UDP packet must not consume the deadline needed by HTTP/2 and HTTP/1.1 fallback.

conn, response, err := websocket.Dial(ctx, "wss://example.test/events", websocket.DialOptions{})
// conn is identical to use whether response.ProtoMajor is 2 or 1.

Go 1.24–1.26 guards server advertisement of RFC 8441 behind the upstream HTTP/2 compatibility switch. Start server processes with GODEBUG=http2xconnect=1; no handler changes are required. Clients do not need this setting. The zero-configuration secure client transport is shared, so concurrent WebSockets multiplex on one HTTP/2 connection. Supplying HTTP2Transport allows the application to own that shared transport when it needs custom TLS, dialing, or lifecycle policy.

Go callers can use the concise WriteText, WriteBinary, WritePing, WritePong, and WriteClose methods. Go+ callers can instead construct and exhaustively match the closed Message enum; indexed Capability[Phase] values make opening and closing transitions explicit in protocol orchestration.

capability := websocket.OpenCapability(conn)
capability, err = websocket.Send(capability,
    websocket.TextMessage([]byte("hello")))
attempt := websocket.BeginClose(capability, websocket.CloseNormalClosure, "done")
match attempt {
case CloseStarted(closing):
    closed, err := websocket.FinishClose(closing)
case CloseFailed(open, cause):
    // `open` retains ownership, so the caller can recover or retry.
}

The capability is quantity-1: Go+ proves it is consumed exactly once on every path. Generated Go carries the same guarantee with a use-once Lin cell and runtime index guards. This layer is optional; direct Conn calls remain the idiomatic Go API.

WriteMessage preserves caller-owned payload bytes. WriteMessageOwned transfers ownership and avoids the defensive masking copy on clients. One reader and one writer may operate concurrently; writes are serialized.

Conformance and performance

The complete Autobahn 25.10.1 server and client gates require Podman. The runner pins the suite image by digest so the 517-case contract cannot drift:

./websocket/autobahn/run-podman.sh
./websocket/autobahn/run-client-podman.sh

Docker Compose users can run websocket/autobahn/run.sh. Reports are written under websocket/autobahn/reports/ and the verifier fails on any non-passing required case.

The comparative gobwas/ws performance contract is:

go run ./websocket/cmd/benchgate

The handwritten implementation is held at complete statement coverage:

go test -coverprofile=/tmp/websocket.cover ./websocket
go run ./websocket/cmd/covergate -profile /tmp/websocket.cover

Protocol, compression, conformance, coverage, and performance requirements live in features/*.feature; normal tests execute behavioral scenarios, while the coverage and benchmark tags are enforced by their dedicated gates.

Documentation

Overview

Package websocket implements RFC 6455 and RFC 7692 WebSocket clients, servers, framing, masking, message assembly, close validation, and bounded decompression.

Dial and Upgrade are the normal transport entry points. Message is a closed Go+ sum type, so applications handle text, binary, ping, pong, and close without integer message-kind constants. Conn permits one concurrent reader and one concurrent writer and serializes writes to prevent frame interleave.

Low-level users can use ParseHeader, AppendHeader, Mask, and Assembler. Those APIs contain the same validation used by Conn and are allocation-free on the framing hot path.

Package websocket implements RFC 6455 WebSocket framing and transport. The semantic layer is authored in Go+; hot framing paths remain small, allocation-free Go functions so both Go+ and Go callers get the same wire.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNeedMoreData       = io.ErrUnexpectedEOF
	ErrInvalidOpcode      = errors.New("websocket: invalid opcode")
	ErrReservedBits       = errors.New("websocket: reserved bits set")
	ErrWrongMask          = errors.New("websocket: incorrect masking for peer role")
	ErrNonCanonicalLength = errors.New("websocket: non-canonical payload length")
	ErrControlFragmented  = errors.New("websocket: fragmented control frame")
	ErrControlTooLarge    = errors.New("websocket: control payload exceeds 125 bytes")
	ErrInvalidLength      = errors.New("websocket: invalid payload length")
)
View Source
var (
	ErrUnexpectedContinuation = errors.New("websocket: unexpected continuation")
	ErrExpectedContinuation   = errors.New("websocket: expected continuation")
	ErrInvalidUTF8            = errors.New("websocket: invalid UTF-8")
	ErrInvalidClosePayload    = errors.New("websocket: invalid close payload")
	ErrInvalidCloseCode       = errors.New("websocket: invalid close code")
	ErrMessageTooLarge        = errors.New("websocket: message exceeds configured limit")
)
View Source
var ErrHandshake = errors.New("websocket: invalid opening handshake")
View Source
var ErrInvalidExtension = errors.New("websocket: invalid extension negotiation")

Functions

func AcceptKey

func AcceptKey(key string) string

AcceptKey computes Sec-WebSocket-Accept without heap allocation except for the returned string.

func AppendClosePayload

func AppendClosePayload(dst []byte, code CloseCode, reason string) ([]byte, error)

func AppendFrame added in v0.18.1

func AppendFrame(dst []byte, h Header, payload []byte) ([]byte, error)

AppendFrame appends a complete frame to dst. It copies payload and applies the mask to the appended copy, preserving caller ownership. Reusing dst makes complete frame construction allocation-free.

func AppendHeader

func AppendHeader(dst []byte, h Header) ([]byte, error)

AppendHeader validates h and appends its canonical wire representation. It allocates only when dst lacks capacity.

func CapabilityFold added in v0.18.1

func CapabilityFold[R any](v Capability, cs CapabilityCases[R]) R

CapabilityFold reduces Capability by one-level case analysis.

func FailureEqual

func FailureEqual(a, b Failure) bool

FailureEqual reports structural equality of a and b.

func FailureEqualWith

func FailureEqualWith(a, b Failure, ov FailureEqOverrides) bool

FailureEqualWith reports structural equality of a and b under ov.

func FailureFold

func FailureFold[R any](f Failure, cs FailureCases[R]) R

FailureFold reduces Failure by one-level case analysis.

func IsControl

func IsControl(op Opcode) bool

func IsRFC8441Request added in v0.19.0

func IsRFC8441Request(r *http.Request) bool

IsRFC8441Request reports whether r is an HTTP/2 WebSocket extended CONNECT request. It does not imply that the rest of the opening handshake is valid.

func IsRFC9220Request added in v0.20.0

func IsRFC9220Request(r *http.Request) bool

IsRFC9220Request reports whether r is an HTTP/3 WebSocket extended CONNECT request. It does not imply that the rest of the handshake is valid.

func Mask

func Mask(payload []byte, key [4]byte, offset int) int

func PhaseEqual

func PhaseEqual(a, b Phase) bool

PhaseEqual reports structural equality of a and b.

func PhaseEqualWith

func PhaseEqualWith(a, b Phase, ov PhaseEqOverrides) bool

PhaseEqualWith reports structural equality of a and b under ov.

func PhaseFold

func PhaseFold[R any](p Phase, cs PhaseCases[R]) R

PhaseFold reduces Phase by one-level case analysis.

func SameOrigin

func SameOrigin(r *http.Request) bool

SameOrigin accepts non-browser clients without Origin and otherwise requires the Origin host to match the HTTP Host header. Pass it as UpgradeOptions.CheckOrigin for browser-facing endpoints.

func Serve

func Serve(listener net.Listener, handler func(*Conn)) error

Serve accepts raw TCP connections and applies handler after an HTTP upgrade. It is intentionally small; net/http Upgrade is the preferred server API.

func ValidCloseCode

func ValidCloseCode(code CloseCode) bool

func ValidOpcode

func ValidOpcode(op Opcode) bool

func ValidateServerRequest

func ValidateServerRequest(r *http.Request) (string, error)

ValidateServerRequest checks every mandatory RFC 6455 server-side opening handshake condition and returns the trimmed nonce.

Types

type Assembler

type Assembler struct {
	MaxMessage int64
	// contains filtered or unexported fields
}

Assembler validates fragmentation and turns frames into complete messages. A nil message means a non-final data fragment was accepted.

func (*Assembler) Feed

func (a *Assembler) Feed(h Header, payload []byte) (Message, error)

func (*Assembler) Reset

func (a *Assembler) Reset()

type BinaryMessage

type BinaryMessage struct {
	Payload []byte
}

type Capability added in v0.18.1

type Capability interface {
	// contains filtered or unexported methods
}

Capability is the Go+ ownership-oriented API. Go callers that do not want typestate use Conn directly.

func FinishClose added in v0.18.1

func FinishClose(capability Lin[Capability]) (Capability, error)

func Send added in v0.18.1

func Send(capability Lin[Capability], message Message) (Capability, error)

Send consumes and returns the open capability, preventing concurrent or accidental duplicated ownership in Go+ orchestration.

type CapabilityCases added in v0.18.1

type CapabilityCases[R any] struct {
	OpenCapability      func(conn *Conn) R
	CloseSentCapability func(conn *Conn) R
	ClosedCapability    func(conn *Conn) R
}

CapabilityCases selects one handler per Capability variant for CapabilityFold.

type CloseAttempt added in v0.18.1

type CloseAttempt interface {
	// contains filtered or unexported methods
}

CloseAttempt preserves ownership on both the success and failure paths.

func BeginClose added in v0.18.1

func BeginClose(capability Lin[Capability], code CloseCode, reason string) CloseAttempt

type CloseCode

type CloseCode uint16
const (
	CloseNormalClosure   CloseCode = 1000
	CloseGoingAway       CloseCode = 1001
	CloseProtocolError   CloseCode = 1002
	CloseUnsupportedData CloseCode = 1003
	CloseInvalidPayload  CloseCode = 1007
	ClosePolicyViolation CloseCode = 1008
	CloseMessageTooBig   CloseCode = 1009
	CloseMandatoryExt    CloseCode = 1010
	CloseInternalError   CloseCode = 1011
)

func ParseClosePayload

func ParseClosePayload(payload []byte) (CloseCode, string, error)

type CloseFailed added in v0.18.1

type CloseFailed struct {
	Capability Capability
	Err        error
}

type CloseMessage

type CloseMessage struct {
	Code   CloseCode
	Reason string
}

type CloseReceivedPhase

type CloseReceivedPhase struct{}

type CloseReceivedSession

type CloseReceivedSession struct{}

type CloseSentCapability added in v0.18.1

type CloseSentCapability struct {
	Conn *Conn
}

type CloseSentPhase

type CloseSentPhase struct{}

type CloseSentSession

type CloseSentSession struct{}

type CloseStarted added in v0.18.1

type CloseStarted struct {
	Capability Capability
}

type ClosedCapability added in v0.18.1

type ClosedCapability struct {
	Conn *Conn
}

type ClosedPhase

type ClosedPhase struct{}

type ClosedSession

type ClosedSession struct{}

type CompressionOptions

type CompressionOptions struct {
	ClientMaxWindowBits        int
	ServerMaxWindowBits        int
	AllowClientContextTakeover bool
	AllowServerContextTakeover bool
}

CompressionOptions enables RFC 7692 permessage-deflate. Window-bit values are zero (do not advertise) or 8..15. This implementation always negotiates no-context-takeover in both directions, making each message independently decodable and bounding memory retained between messages.

type Conn

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

Conn is a concurrency-safe WebSocket connection. One reader and one writer may operate concurrently; writes are serialized so frames never interleave.

func Dial

func Dial(ctx context.Context, rawURL string, opts DialOptions) (*Conn, *http.Response, error)

Dial opens a WebSocket using RFC 8441 when selected and RFC 6455 otherwise. On success the returned response is metadata only; Conn exclusively owns the underlying transport stream, so callers may safely ignore response.Body.

func NewConn

func NewConn(rw io.ReadWriteCloser, side Side, buffered *bufio.Reader, cfg ConnConfig) *Conn

func Upgrade

func Upgrade(w http.ResponseWriter, r *http.Request, opts UpgradeOptions) (*Conn, string, error)

Upgrade accepts an RFC 6455 HTTP/1.1 request and preserves bytes already buffered after the handshake.

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) HandshakeProtocol added in v0.19.0

func (c *Conn) HandshakeProtocol() HandshakeProtocol

HandshakeProtocol reports whether RFC 6455 Upgrade or RFC 8441 extended CONNECT established the connection.

func (*Conn) NetConn

func (c *Conn) NetConn() net.Conn

func (*Conn) ReadMessage

func (c *Conn) ReadMessage() (Message, error)

ReadMessage returns the next complete data or close message. Ping is answered automatically; Pong is surfaced so applications can track liveness.

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

func (*Conn) WriteBinary added in v0.18.1

func (c *Conn) WriteBinary(payload []byte) error

func (*Conn) WriteBinaryOwned added in v0.18.1

func (c *Conn) WriteBinaryOwned(payload []byte) error

func (*Conn) WriteClose added in v0.18.1

func (c *Conn) WriteClose(code CloseCode, reason string) error

WriteClose starts the RFC 6455 closing handshake without immediately closing the underlying transport.

func (*Conn) WriteMessage

func (c *Conn) WriteMessage(message Message) error

func (*Conn) WriteMessageOwned

func (c *Conn) WriteMessageOwned(message Message) error

WriteMessageOwned may mask the message payload in place on client connections. Callers that transfer ownership can use it to avoid the one defensive payload copy required by WriteMessage.

func (*Conn) WritePing added in v0.18.1

func (c *Conn) WritePing(payload []byte) error

func (*Conn) WritePong added in v0.18.1

func (c *Conn) WritePong(payload []byte) error

func (*Conn) WriteText added in v0.18.1

func (c *Conn) WriteText(payload []byte) error

WriteText and WriteBinary are concise Go-facing forms of WriteMessage.

func (*Conn) WriteTextOwned added in v0.18.1

func (c *Conn) WriteTextOwned(payload []byte) error

WriteTextOwned and WriteBinaryOwned transfer payload ownership, allowing a client connection to mask in place instead of making a defensive copy.

type ConnConfig

type ConnConfig struct {
	MaxFrame   int64
	MaxMessage int64
	// ManualControl surfaces Ping messages instead of answering them
	// automatically. Close handshake responses remain automatic.
	ManualControl bool
}

type ConnectingPhase

type ConnectingPhase struct{}

type ConnectingSession

type ConnectingSession struct{}

type ControlFragmented

type ControlFragmented struct{}

type ControlTooLarge

type ControlTooLarge struct{}

type DialOptions

type DialOptions struct {
	Protocols []string
	Header    http.Header
	TLSConfig *tls.Config
	NetDialer *net.Dialer
	// DialContext overrides TCP connection establishment, enabling proxies,
	// custom transports, and deterministic fault injection.
	DialContext func(context.Context, string, string) (net.Conn, error)
	Config      ConnConfig
	Compression *CompressionOptions
	// HTTP3 controls RFC 9220 extended CONNECT. Auto tries HTTP/3 when an
	// HTTP3Transport supplies learned origin capability, then falls back to
	// HTTP/2 and HTTP/1.1 when the transport is unavailable. HTTP/3 always
	// uses TLS.
	HTTP3 HTTP3Mode
	// HTTP3Transport optionally supplies a shared HTTP/3 transport. The
	// transport must support extended CONNECT and a streaming request body.
	HTTP3Transport http.RoundTripper
	// QUICConfig configures QUIC when the package owns the HTTP/3 transport.
	QUICConfig *quic.Config
	// HTTP2 controls RFC 8441 extended CONNECT. Auto prefers HTTP/2 for wss
	// URLs and transparently falls back to RFC 6455. Cleartext ws remains on
	// HTTP/1.1 unless HTTP2Only is selected.
	HTTP2 HTTP2Mode
	// HTTP2Transport optionally supplies a shared HTTP/2-capable transport.
	// It must preserve a streaming request body and response body.
	HTTP2Transport http.RoundTripper
}

type ExpectedContinuation

type ExpectedContinuation struct{}

type Failure

type Failure interface {
	// contains filtered or unexported methods
}

Failure classifies protocol failure without string matching.

func FailureOf

func FailureOf(err error) Failure

FailureOf lifts an ordinary Go error into the closed Go+ Failure vocabulary. It lets Go+ callers exhaustively fold protocol failures while preserving an unknown transport error for ordinary errors.Is/errors.As handling.

type FailureCases

type FailureCases[R any] struct {
	NeedMoreData           func() R
	InvalidOpcode          func(opcode byte) R
	ReservedBits           func(bits byte) R
	WrongMask              func(expectMasked bool) R
	NonCanonicalLength     func() R
	ControlFragmented      func() R
	ControlTooLarge        func() R
	UnexpectedContinuation func() R
	ExpectedContinuation   func() R
	InvalidUTF8            func() R
	InvalidClosePayload    func() R
	InvalidCloseCode       func(code CloseCode) R
	MessageTooLarge        func(limit int64) R
	HandshakeRejected      func(status int, reason string) R
	TransportFailed        func(err error) R
}

FailureCases selects one handler per Failure variant for FailureFold.

type FailureEqOverrides

type FailureEqOverrides struct {
	NeedMoreData           func(x, y NeedMoreData) (eq, handled bool)
	InvalidOpcode          func(x, y InvalidOpcode) (eq, handled bool)
	ReservedBits           func(x, y ReservedBits) (eq, handled bool)
	WrongMask              func(x, y WrongMask) (eq, handled bool)
	NonCanonicalLength     func(x, y NonCanonicalLength) (eq, handled bool)
	ControlFragmented      func(x, y ControlFragmented) (eq, handled bool)
	ControlTooLarge        func(x, y ControlTooLarge) (eq, handled bool)
	UnexpectedContinuation func(x, y UnexpectedContinuation) (eq, handled bool)
	ExpectedContinuation   func(x, y ExpectedContinuation) (eq, handled bool)
	InvalidUTF8            func(x, y InvalidUTF8) (eq, handled bool)
	InvalidClosePayload    func(x, y InvalidClosePayload) (eq, handled bool)
	InvalidCloseCode       func(x, y InvalidCloseCode) (eq, handled bool)
	MessageTooLarge        func(x, y MessageTooLarge) (eq, handled bool)
	HandshakeRejected      func(x, y HandshakeRejected) (eq, handled bool)
	TransportFailed        func(x, y TransportFailed) (eq, handled bool)
}

FailureEqOverrides carries optional per-variant hooks for FailureEqualWith. A hook returning handled=false falls through to the derived comparison.

type HTTP2Mode added in v0.19.0

type HTTP2Mode uint8

HTTP2Mode controls selection of the opening-handshake transport.

const (
	// HTTP2Auto prefers RFC 8441 for secure WebSockets and falls back to RFC
	// 6455 when the peer does not support extended CONNECT. Cleartext ws uses
	// RFC 6455 unless a custom HTTP2Transport is supplied.
	HTTP2Auto HTTP2Mode = iota
	// HTTP1Only disables RFC 8441 and always uses the RFC 6455 Upgrade.
	HTTP1Only
	// HTTP2Only requires RFC 8441, including h2c prior knowledge for ws URLs.
	HTTP2Only
)

type HTTP3Mode added in v0.20.0

type HTTP3Mode uint8

HTTP3Mode controls RFC 9220 selection.

const (
	// HTTP3Auto prefers RFC 9220 for secure WebSockets and falls back through
	// RFC 8441 to RFC 6455 when HTTP/3 is unavailable.
	HTTP3Auto HTTP3Mode = iota
	// HTTP3Disabled skips HTTP/3.
	HTTP3Disabled
	// HTTP3Only requires RFC 9220.
	HTTP3Only
)

type HandshakeProtocol added in v0.19.0

type HandshakeProtocol uint8

HandshakeProtocol identifies how a WebSocket connection was bootstrapped.

const (
	RFC6455Handshake HandshakeProtocol = iota
	RFC8441Handshake
	RFC9220Handshake
)

func (HandshakeProtocol) String added in v0.19.0

func (p HandshakeProtocol) String() string

type HandshakeRejected

type HandshakeRejected struct {
	Status int
	Reason string
}
type Header struct {
	Length int64
	Mask   [4]byte
	Opcode Opcode
	FIN    bool
	RSV1   bool
	RSV2   bool
	RSV3   bool
	Masked bool
}

Header is the RFC 6455 frame header. Length is limited to 63 bits.

func ParseHeader

func ParseHeader(src []byte, side Side, allowRSV1 bool) (h Header, consumed int, err error)

ParseHeader parses and validates a frame header without allocation. side is the local side, so ServerSide requires a masked incoming frame.

type InvalidCloseCode

type InvalidCloseCode struct {
	Code CloseCode
}

type InvalidClosePayload

type InvalidClosePayload struct{}

type InvalidOpcode

type InvalidOpcode struct {
	Opcode byte
}

type InvalidUTF8

type InvalidUTF8 struct{}

type Lin added in v0.18.1

type Lin[T any] struct {
	// contains filtered or unexported fields
}

Lin carries a linear (use-exactly-once) value across the erased boundary; Use panics on reuse.

func LinOf added in v0.18.1

func LinOf[T any](v T) Lin[T]

LinOf wraps a value for a linear parameter.

func (Lin[T]) Use added in v0.18.1

func (c Lin[T]) Use() T

Use consumes the value; a second Use panics.

type Message

type Message interface {
	// contains filtered or unexported methods
}

Message is the complete application/control message vocabulary.

type MessageTooLarge

type MessageTooLarge struct {
	Limit int64
}

type NeedMoreData

type NeedMoreData struct{}

type NonCanonicalLength

type NonCanonicalLength struct{}

type Opcode

type Opcode byte
const (
	OpContinuation Opcode = 0x0
	OpText         Opcode = 0x1
	OpBinary       Opcode = 0x2
	OpClose        Opcode = 0x8
	OpPing         Opcode = 0x9
	OpPong         Opcode = 0xa
)

type OpenCapability added in v0.18.1

type OpenCapability struct {
	Conn *Conn
}

type OpenPhase

type OpenPhase struct{}

type OpenSession

type OpenSession struct{}

type Phase

type Phase interface {
	// contains filtered or unexported methods
}

Phase indexes the protocol transitions that are valid for a connection.

type PhaseCases

type PhaseCases[R any] struct {
	ConnectingPhase    func() R
	OpenPhase          func() R
	CloseSentPhase     func() R
	CloseReceivedPhase func() R
	ClosedPhase        func() R
}

PhaseCases selects one handler per Phase variant for PhaseFold.

type PhaseEqOverrides

type PhaseEqOverrides struct {
	ConnectingPhase    func(x, y ConnectingPhase) (eq, handled bool)
	OpenPhase          func(x, y OpenPhase) (eq, handled bool)
	CloseSentPhase     func(x, y CloseSentPhase) (eq, handled bool)
	CloseReceivedPhase func(x, y CloseReceivedPhase) (eq, handled bool)
	ClosedPhase        func(x, y ClosedPhase) (eq, handled bool)
}

PhaseEqOverrides carries optional per-variant hooks for PhaseEqualWith. A hook returning handled=false falls through to the derived comparison.

type PingMessage

type PingMessage struct {
	Payload []byte
}

type PongMessage

type PongMessage struct {
	Payload []byte
}

type ReservedBits

type ReservedBits struct {
	Bits byte
}

type Session

type Session interface {
	// contains filtered or unexported methods
}

Session is the lightweight proof-token API retained for v0.18 compatibility. New Go+ orchestration should prefer Capability, which also carries linear connection ownership.

func FinishReceived

func FinishReceived(_ Session) Session

func FinishSent

func FinishSent(_ Session) Session

func Open

func Open(_ Session) Session

func ReceivedClose

func ReceivedClose(_ Session) Session

func SentClose

func SentClose(_ Session) Session

type Side

type Side byte
const (
	ServerSide Side = iota // receives masked frames, writes unmasked frames
	ClientSide             // receives unmasked frames, writes masked frames
)

type TextMessage

type TextMessage struct {
	Payload []byte
}

type TransportFailed

type TransportFailed struct {
	Err error
}

type UnexpectedContinuation

type UnexpectedContinuation struct{}

type UpgradeOptions

type UpgradeOptions struct {
	Protocols   []string
	CheckOrigin func(*http.Request) bool
	Config      ConnConfig
	Compression *CompressionOptions
}

type WrongMask

type WrongMask struct {
	ExpectMasked bool
}

Directories

Path Synopsis
autobahn
verify command
cmd
autobahn-client command
Command autobahn-client runs this implementation against an Autobahn fuzzingserver instance.
Command autobahn-client runs this implementation against an Autobahn fuzzingserver instance.
autobahn-server command
benchgate command
Command benchgate executes the comparative performance contract.
Command benchgate executes the comparative performance contract.
covergate command

Jump to

Keyboard shortcuts

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