masque

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 36 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func NewHandler

func NewHandler(opts ...handler.Option) handler.Handler

NewHandler creates a new MASQUE handler instance. It supports CONNECT-UDP (RFC 9298) for UDP proxying and standard HTTP/3 CONNECT (RFC 9114) for TCP tunneling. The returned handler must be initialized via Init() before use.

Types

This section is empty.

Jump to

Keyboard shortcuts

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