proxy

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

Conn represents a proxy connection

func (*Conn) Copy

func (pc *Conn) Copy(dst net.Conn)

Copy bidirectional copy with dst connection

func (*Conn) PeekClientHello

func (pc *Conn) PeekClientHello() (*tls.ClientHelloInfo, error)

PeekClientHello attempts to read TLS ClientHello from the connection without consuming the TLS handshake.

func (*Conn) WriteHeader

func (pc *Conn) WriteHeader(code int)

WriteHeader writes an HTTP status header to the proxy client. It must be called before any writes to ProxyConn otherwise http.StatusOK is written.

type Handler

type Handler struct {
	// Tunneler specifies the mechanism for handling HTTP CONNECT
	// tunnels.
	Tunneler Tunneler

	// NonConnect is used for all other HTTP requests where HTTP method != CONNECT
	NonConnect http.Handler
}

A Handler implements http.Handler for running a proxy.

func (*Handler) ServeHTTP

func (p *Handler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Tunneler

type Tunneler interface {
	// Tunnel opens a tunnel for a given request
	// between clientConn and the target addr
	Tunnel(ctx context.Context, clientConn *Conn, network, addr string)
}

Tunneler is an interface representing the ability to handle a single HTTP CONNECT request by opening a tunnel for a given Request.

type TunnelerFunc

type TunnelerFunc func(ctx context.Context, clientConn *Conn, network, addr string)

The TunnelerFunc type is an adapter to allow the use of an ordinary function as a tunneler.

func (TunnelerFunc) Tunnel

func (t TunnelerFunc) Tunnel(ctx context.Context, clientConn *Conn, network, addr string)

Jump to

Keyboard shortcuts

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