Documentation
¶
Overview ¶
Package http2 implements an HTTP/2 proxy handler. It supports both forward proxy (GET/POST/CONNECT) and tunnel modes with optional probe resistance, bypass, traffic limiting, and observability.
The handler is registered under the name "http2" and created via NewHandler in init(). It is designed for use with HTTP/2 (h2/h2c) listeners.
Request processing flow ¶
Each inbound net.Conn is handled by Handle, which delegates to roundTrip for authentication, bypass checks, routing, and forwarding.
Handle()
├─ checkRateLimit (connection rate limiter, if configured)
├─ ictx.MetadataFromContext (extract w, r from HTTP/2 stream context)
└─ roundTrip()
├─ decodeServerName (TNET 2.x compatibility headers)
├─ authenticate (basic proxy auth + probe resistance)
├─ bypass check
├─ set metadata response headers
├─ Router.Dial (connect to upstream)
├─ forwardRequest (non-CONNECT: wrap with traffic limiter + stats, proxy request + error response on failure)
└─ CONNECT tunnel (bi-directional pipe with idle timeout)
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrAuthFailed = errors.New("http2: authentication failed") ErrWrongConnType = errors.New("http2: wrong connection type") )
Sentinel errors returned by the HTTP/2 handler.
Functions ¶
func NewHandler ¶
NewHandler creates a new HTTP/2 proxy handler. It supports forward proxy (GET/POST/CONNECT) and tunnel modes with optional probe resistance, bypass, traffic limiting, and observability. The handler is registered under the name "http2" and is intended for use with HTTP/2 (h2/h2c) listeners.
Types ¶
This section is empty.