http2

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 40 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 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

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

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

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.

Jump to

Keyboard shortcuts

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