handlers

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTransport = &http.Transport{
	Proxy: http.ProxyFromEnvironment,
	DialContext: (&net.Dialer{
		Timeout:   30 * time.Second,
		KeepAlive: 30 * time.Second,
	}).DialContext,
	MaxIdleConns:          100,
	IdleConnTimeout:       90 * time.Second,
	TLSHandshakeTimeout:   10 * time.Second,
	ExpectContinueTimeout: 1 * time.Second,
	MaxIdleConnsPerHost:   runtime.GOMAXPROCS(0) + 1,
	TLSClientConfig: &tls.Config{
		InsecureSkipVerify: true,
	},
	DisableCompression: true,
	DisableKeepAlives:  false,
}

DefaultTransport is the default transport for HTTPHandler to execute HTTP requests

Functions

This section is empty.

Types

type HTTPHandler

type HTTPHandler struct {
	// Transport specifies optional transport to use for making requests to target servers.
	//
	// If Transport is nil, DefaultTransport is used.
	Transport http.RoundTripper

	// Instruct httputil.ReverseProxy to skip the addition of X-Forwarded-For header
	NoXForwardedFor bool
	// contains filtered or unexported fields
}

HTTPHandler is a plain HTTP proxy capable of serving any method except for CONNECT.

The zero value for HTTPHandler is a valid instance.

func (*HTTPHandler) ServeHTTP

func (s *HTTPHandler) ServeHTTP(rw http.ResponseWriter, rq *http.Request)

type MITMHandler

type MITMHandler struct {
	// Handler is an optional http.Handler which will be used by the proxy to serve intercepted sub-requests
	//
	// If nil, zero value of HTTPProxy will be used.
	Handler http.Handler

	// Issuer specifies optional certificate issuer.
	//
	// If Issuer is nil, issuer.SelfSignedCA will be used.
	Issuer issuer.Issuer

	// CertCacheSize specifies the size of certificate cache used by the proxy.
	//
	// If CertCacheSize is 0, platform-specific max int value will be used.
	CertCacheSize int
	// contains filtered or unexported fields
}

MITMHandler is an HTTP proxy which handles CONNECT requests using Man-in-the-Middle technique.

The zero value of MITMHandler is a valid http.Handler.

func (*MITMHandler) ServeHTTP

func (s *MITMHandler) ServeHTTP(rw http.ResponseWriter, rq *http.Request)

type Tunnel

type Tunnel struct {

	// DialContext specifies the dial function for creating unencrypted TCP connections.
	//
	// If DialContext is nil then the proxy dials using package net.
	DialContext func(context.Context, string, string) (net.Conn, error)

	// DialTimeout specifies an optional timeout for the dialer to establish upstream connection.
	DialTimeout time.Duration
	// contains filtered or unexported fields
}

Tunnel is a proxy server capable of serving CONNECT requests.

The zero value of Tunnel is a valid instance.

func (*Tunnel) ServeHTTP

func (s *Tunnel) ServeHTTP(rw http.ResponseWriter, rq *http.Request)

Jump to

Keyboard shortcuts

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