Documentation
¶
Overview ¶
Package masque implements a MASQUE (Multiplexed Application Substrate over QUIC Encryption) proxy handler for TNET. MASQUE is an IETF standard for tunneling IP traffic over HTTP/3, used by systems like Apple's iCloud Private Relay.
This handler implements two proxy modes over HTTP/3 (QUIC):
CONNECT-UDP (RFC 9298): Proxies UDP datagrams via HTTP/3 Datagram frames (RFC 9297). The client sends an Extended CONNECT request with :protocol="connect-udp" to the well-known path "/.well-known/masque/udp/{host}/{port}/". UDP packets are then exchanged as HTTP/3 datagrams with a context ID prefix per RFC 9297.
CONNECT-TCP (RFC 9114): Tunnels TCP connections over HTTP/3 stream bodies. The client sends a standard HTTP/3 CONNECT request with the target in the :authority pseudo-header. Data is then relayed bidirectionally through the HTTP/3 stream.
Request flow ¶
The HTTP/3 listener injects the http.ResponseWriter and http.Request into the context metadata. Handle() extracts them, validates the CONNECT method, and dispatches to handleConnectUDP or handleConnectTCP based on the :protocol pseudo-header (stored in r.Proto by quic-go).
Cross-cutting concerns ¶
The handler integrates with TNET's cross-cutting infrastructure: HTTP Basic proxy authentication, bypass rules, rate limiting, traffic limiting, Prometheus metrics, observer event reporting, and traffic recording.
Registration ¶
The handler is registered as "masque" in the handler registry via init(). It must be paired with an HTTP/3 listener (registered as "h3") to function.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBadRequest indicates the request was malformed or invalid. ErrBadRequest = errors.New("masque: bad request") // ErrMethodNotAllowed indicates the request method is not CONNECT. ErrMethodNotAllowed = errors.New("masque: method not allowed") // ErrCapsuleRequired indicates the Capsule-Protocol header is missing or invalid. ErrCapsuleRequired = errors.New("masque: capsule-protocol header required") // ErrDatagramNotSupport indicates that the QUIC connection does not support HTTP/3 datagrams. ErrDatagramNotSupport = errors.New("masque: datagrams not supported") )
Functions ¶
Types ¶
This section is empty.