Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateCA ¶
Types ¶
type CertManager ¶
type CertManager struct {
// contains filtered or unexported fields
}
func NewCertManager ¶
func NewCertManager(certFile, keyFile string) (*CertManager, error)
func (*CertManager) TLSConfig ¶
func (m *CertManager) TLSConfig() *tls.Config
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is an http.Handler that acts as a forward proxy and performs TLS interception (MITM) on CONNECT tunnels when a CertManager is provided.
func New ¶
func New(certMgr *CertManager) *Handler
New creates a Handler. Providing a non-nil certMgr enables TLS interception; passing nil falls back to a transparent TCP relay for CONNECT tunnels.
The caller should set http.Server.BaseContext to a context that is canceled on shutdown so that long-lived CONNECT tunnels are torn down promptly when the server stops.
func (*Handler) ListenAndServe ¶
ListenAndServe starts an HTTP proxy server on the given network address. It uses ctx as the BaseContext for all incoming connections and shuts down gracefully when ctx is canceled.
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP implements http.Handler. CONNECT requests initiate a tunnel; all other methods run request middlewares then are proxied via the reverse proxy.
func (*Handler) UseRequest ¶
func (h *Handler) UseRequest(fn RequestFunc)
UseRequest registers fn as a request middleware. Middlewares are called in registration order before each upstream request.
func (*Handler) UseResponse ¶
func (h *Handler) UseResponse(fn ResponseFunc)
UseResponse registers fn as a response middleware. Middlewares are called in registration order after each upstream response.
type RequestFunc ¶
RequestFunc is called before a request is forwarded to the upstream server.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
blocker
command
Command blocker demonstrates the Blocker interceptor with various response helpers.
|
Command blocker demonstrates the Blocker interceptor with various response helpers. |
|
dump
command
Command dump demonstrates the Dump interceptor, which prints every proxied request and response in HTTP/1.1 wire format to stderr.
|
Command dump demonstrates the Dump interceptor, which prints every proxied request and response in HTTP/1.1 wire format to stderr. |
|
genca
command
Command genca generates a self-signed ECDSA CA certificate and private key for use with the MITM proxy.
|
Command genca generates a self-signed ECDSA CA certificate and private key for use with the MITM proxy. |
|
header
command
Command header demonstrates the Header interceptor helpers: injecting headers into upstream requests and stripping or adding headers on responses.
|
Command header demonstrates the Header interceptor helpers: injecting headers into upstream requests and stripping or adding headers on responses. |
|
logger
command
Command logger demonstrates how to attach the Logger interceptor to a MITM proxy to log every proxied request and response.
|
Command logger demonstrates how to attach the Logger interceptor to a MITM proxy to log every proxied request and response. |
|
proxy
command
Command proxy is a minimal MITM HTTP/HTTPS proxy built on github.com/aomori446/mitm.
|
Command proxy is a minimal MITM HTTP/HTTPS proxy built on github.com/aomori446/mitm. |