Documentation
¶
Overview ¶
Package wire is the shared G1 frame envelope (build-plan.md gap resolution G1): one length-prefixed, type-tagged frame carries every message on both the client<->daemon and daemon<->shim sockets.
Wire format: a 4-byte big-endian length L, then 1 type byte, then L-1 payload bytes. L == len(payload)+1, so an empty payload has L == 1 and a maximal payload (MaxFrame-1 bytes) has L == MaxFrame.
Index ¶
Constants ¶
const MaxFrame = 1 << 20 // 1 MiB
MaxFrame is the largest legal declared frame length L (payload+1 type byte), the anti-DoS cap enforced before any body allocation or read.
internal/skeleton's connection demux (handleConn) routes a fresh connection to the protocol server the instant its first byte is 0x00, relying on every legal frame's 4-byte big-endian length prefix having a zero most-significant byte — see the guard immediately below, which fails to compile if that ever stops holding.
Variables ¶
var ErrFrameTooLarge = errors.New("wire: frame exceeds MaxFrame")
ErrFrameTooLarge is returned when a payload (WriteFrame) or a declared length (ReadFrame) exceeds MaxFrame.
var ErrUnknownType = errors.New("wire: unknown frame type")
ErrUnknownType is returned when a frame's type tag is outside the frozen set above.
Functions ¶
Types ¶
type Type ¶
type Type byte
Type identifies the payload a frame carries.
The frozen set of frame types.
func ReadFrame ¶
ReadFrame reads one frame from r and returns its type and payload.
The declared length is checked against MaxFrame before any body allocation or read (the anti-DoS cap). A reader exhausted exactly at a frame boundary yields io.EOF; a truncated header or body yields io.ErrUnexpectedEOF.