Skip to main content

Module wss

Module wss 

Source
Expand description

Authenticated WebSocket binary-datagram relay (RFC 6455). Local TCP; not a public URL.

Structs§

ReadCursor
Partial-read assembly. Oversize / 8-byte / fragmented poisons the cursor. A short out after a complete frame is Capacity and does not drop it.
WriteCursor
Sealed pending write. WouldBlock retains exact wire bytes; off advances only on Ok(n > 0). A different payload while pending is Conflict.

Enums§

FrameType

Constants§

ENVELOPE_HDR
ENVELOPE_VERSION
ENV_ADDR
ENV_CHILD
ENV_SECRET
MAX_FRAME
MAX_PAYLOAD
OP_BINARY
RFC 6455 binary opcode. FIN is set at encode.
OP_CLOSE
RFC 6455 close opcode. FIN is set at encode.
WIRE_CAP
Sealed WS frame capacity (WS_HDR_MAX + MAX_FRAME).
WS_HDR_MAX
2-byte base + 2-byte ext-len + 4-byte mask.

Functions§

accept_key
RFC 6455 Sec-WebSocket-Accept: base64(SHA-1(key + GUID)).
check_circuit_gen
Bound circuit/generation. Wrong circuit is unauthorized; older/other gen is stale.
client_handshake
Drives the client-side WSS handshake on stream with key_b64.
close_and_shutdown
Send opcode-8 Close with envelope (circuit, gen) then TCP half-close.
decode_envelope
Decodes a frame envelope; fails closed on bad version/obsolete format/truncation.
dial
TCP-connects to addr then performs client handshake + auth exchange under secret.
encode_envelope
Encodes a versioned frame envelope (type, circuit, gen, len, payload) into out; fails closed on capacity.
expect_auth
Reads and verifies the peer’s auth frame; fails closed on mismatch.
fresh_client_mask
Fill a 4-byte client mask from OS entropy. Fail closed on entropy failure.
hmac_auth
HMAC-SHA256 over (circuit, gen) under secret — per-circuit auth token.
io_from_qdnf
Wrap a QDNF outcome as io::Error so existing send_datagram callers keep io::Result. Bearer paths downcast via map_io.
local_authenticated_wss_executed
Set after a successful local two-process WSS exchange.
loopback_pair
Pair of already-upgraded WebSocket ends (same process).
map_io
Map std::io::Error onto a QDNF outcome. Recovers a wrapped QdnfError.
recv_checked
Receive one WS frame, decode the envelope, and refuse wrong circuit / stale gen.
recv_datagram
Receives a datagram frame; returns (circuit, gen, payload).
seal_close
Seal an application Close envelope as RFC 6455 opcode 8. Same pending close resumes. A pending datagram is Conflict and is not aborted or resealed.
seal_datagram
Seal an application envelope as a WS binary frame. Fresh mask only when idle.
send_auth
Sends the HMAC auth frame for (circuit, gen).
send_datagram
Sends a datagram frame on the circuit.
serve_pair
Local two-client hub: first two accepted sockets exchange datagrams after HMAC.
server_handshake
Drives the server-side handshake — reads the request, responds with the computed accept key.