Skip to main content

Module net

Module net 

Source
Expand description

TCP and UDP relay (docs/design/net.md): opcodes, flags, and the message builders both ends share. TCP and UDP relay wire protocol (docs/design/net.md). A raw socket relay: the client names a host and port, the server opens a socket, and the two ends shuttle payload.

Structs§

NetOpen
A parsed C2S_NET_OPEN.

Constants§

C2S_NET_ACK
Cumulative byte-window credit, TCP only: [0x82][stream_id:2][bytes:8]
C2S_NET_CLOSE
Close or half-close: [0x83][stream_id:2][flags:1]
C2S_NET_DATA
Stream payload, TCP only: [0x81][stream_id:2][data:N]
C2S_NET_DGRAM
One datagram, UDP only: [0x84][stream_id:2][payload:N]
C2S_NET_OPEN
Open a socket: [0x80][stream_id:2][flags:1][port:2][host_len:2][host:N] + TLS block The TLS block ([sni_len:2][sni:N][alpn_count:1] repeated{[proto_len:1][proto:N]}) is present iff NET_OPEN_TLS is set.
FEATURE_NET
S2C_HELLO feature bit: server supports the NET_* family (docs/design/net.md).
NET_CLOSED_BUDGET
Retention or stream budget exceeded.
NET_CLOSED_EOF
NET_CLOSED.reason: the target closed cleanly (TCP).
NET_CLOSED_POLICY
Closed by the server: policy reload, target revoked.
NET_CLOSED_RESET
Connection reset by the target, or ICMP unreachable on a UDP flow.
NET_CLOSED_SHUTDOWN
Server or blit connection going away.
NET_CLOSED_TIMEOUT
Idle timeout — the normal end of a UDP flow.
NET_CLOSE_WRITE
NET_CLOSE.flags bit 0: shut down the client’s write side only, leaving the stream readable.
NET_DGRAM_QUEUE
Per-direction datagram queue depth on a UDP flow.
NET_MAX_CHUNK
Maximum NET_DATA/NET_DGRAM payload.
NET_MAX_DGRAM
Maximum UDP payload — UDP’s own limit, which fits inside NET_MAX_CHUNK.
NET_MAX_HOST
Maximum host length in bytes.
NET_MAX_SOCKETS
Maximum concurrent sockets per blit connection, streams and flows together.
NET_OPEN_FLAGS_KNOWN
Every defined NET_OPEN flag; anything else is INVALID.
NET_OPEN_INSECURE
NET_OPEN.flags bit 1: skip certificate and hostname verification.
NET_OPEN_TLS
NET_OPEN.flags bit 0: terminate TLS toward the target; relayed bytes are the plaintext stream.
NET_OPEN_UDP
NET_OPEN.flags bit 2: open a UDP datagram flow rather than a TCP stream.
NET_STATUS_BUDGET
Concurrent-socket or memory budget exhausted.
NET_STATUS_INVALID
Malformed request: unknown flags, empty host, live stream_id, INSECURE without TLS, TLS block absent with TLS set, UDP combined with TLS or INSECURE.
NET_STATUS_NOT_FOUND
host did not resolve.
NET_STATUS_OK
NET_OPENED.status.
NET_STATUS_OTHER
Anything else; diagnostic in detail.
NET_STATUS_PERMISSION
Target refused by policy (docs/design/net.md § Target policy).
NET_STATUS_REFUSED
Connect refused, unreachable, or timed out.
NET_STATUS_TLS
TLS handshake or certificate verification failed.
NET_STATUS_UNKNOWN_ID
stream_id unknown or already closed.
NET_WINDOW_AGGREGATE
Default aggregate unacked-byte window across all of a connection’s streams, so N streams cannot each claim a full window.
NET_WINDOW_BYTES
Default per-stream unacked-byte window.
S2C_NET_ACK
Cumulative byte-window credit, TCP only: [0x82][stream_id:2][bytes:8]
S2C_NET_CLOSED
Socket ended: [0x83][stream_id:2][reason:1][detail_len:2][detail:N] On a UDP flow detail carries the drop counts, both directions.
S2C_NET_DATA
Stream payload, TCP only: [0x81][stream_id:2][data:N]
S2C_NET_DGRAM
One datagram, UDP only: [0x84][stream_id:2][payload:N]
S2C_NET_OPENED
Open result, one per NET_OPEN: [0x80][stream_id:2][status:1][alpn_len:1][alpn:N][detail_len:2][detail:N]

Functions§

is_c2s_net
True for any C2S opcode in the family’s 0x80 block, for dispatch.
msg_net_ack_c2s
msg_net_ack_s2c
msg_net_close
msg_net_closed
msg_net_data_c2s
msg_net_data_s2c
msg_net_dgram_c2s
msg_net_dgram_s2c
msg_net_open
msg_net_opened
net_closed_text
Human-readable form of a NET_CLOSED.reason, for CLI diagnostics.
net_status_text
Human-readable form of a NET_OPENED.status, for CLI diagnostics.
parse_net_ack_c2s
parse_net_ack_s2c
parse_net_close
Parse a C2S_NET_CLOSE(stream_id, flags).
parse_net_closed
Parse an S2C_NET_CLOSED(stream_id, reason, detail).
parse_net_data_c2s
parse_net_data_s2c
parse_net_dgram_c2s
parse_net_dgram_s2c
parse_net_open
Parse a C2S_NET_OPEN.
parse_net_opened
Parse an S2C_NET_OPENED(stream_id, status, alpn, detail).