proxy

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HttpHeaderContentType            = "Content-Type"
	HttpHeaderConnection             = "Connection"
	HttpHeaderKeepAlive              = "Keep-Alive"
	HttpHeaderProxyAuthenticate      = "Proxy-Authenticate"
	HttpHeaderProxyAuthorization     = "Proxy-Authorization"
	HttpHeaderProxyConnection        = "Proxy-Connection"
	HttpHeaderProxyAgent             = "Proxy-Agent"
	HttpHeaderTe                     = "Te"
	HttpHeaderTrailers               = "Trailers"
	HttpHeaderTransferEncoding       = "Transfer-Encoding"
	HttpHeaderUpgrade                = "Upgrade"
	HttpHeaderSecWebsocketKey        = "Sec-Websocket-Key"
	HttpHeaderSecWebsocketVersion    = "Sec-Websocket-Version"
	HttpHeaderSecWebsocketExtensions = "Sec-Websocket-Extensions"
	HttpHeaderContentEncoding        = "Content-Encoding"
	HttpHeaderContentLength          = "Content-Length"
)

Variables

View Source
var (
	ReqCtxKey   = ReqContextKey{}
	EmptyReqCtx = ReqContext{}
)

Functions

func RemoveHopByHopRequestHeaders

func RemoveHopByHopRequestHeaders(header http.Header)

func RemoveWebsocketRequestHeaders

func RemoveWebsocketRequestHeaders(header http.Header)

Types

type Flow added in v1.1.0

type Flow struct {
	FlowID    uint64
	Timestamp int64
	HTTP      *HTTPFlow
	WS        *WSFlow
}

type HTTPDelegatedInvoker

type HTTPDelegatedInvoker interface {
	Invoke(*http.Request) (*http.Response, error)
}

type HTTPDelegatedInvokerFunc

type HTTPDelegatedInvokerFunc func(*http.Request) (*http.Response, error)

func (HTTPDelegatedInvokerFunc) Invoke

type HTTPFlow added in v1.1.0

type HTTPFlow struct {
	Request  *http.Request
	Response *http.Response
}

func (*HTTPFlow) DumpHTTPRequestView added in v1.1.0

func (f *HTTPFlow) DumpHTTPRequestView() (*HTTPRequestView, error)

func (*HTTPFlow) DumpHTTPResponseView added in v1.1.0

func (f *HTTPFlow) DumpHTTPResponseView() (*HTTPResponseView, error)

func (*HTTPFlow) DumpHTTPView added in v1.1.0

func (f *HTTPFlow) DumpHTTPView() (*HTTPView, error)

type HTTPRequestView added in v1.1.0

type HTTPRequestView struct {
	Method string
	Uri    string
	Proto  string
	Header http.Header
	Body   []byte
}

func (*HTTPRequestView) Encode added in v1.1.0

func (v *HTTPRequestView) Encode() []byte

type HTTPResponseView added in v1.1.0

type HTTPResponseView struct {
	Proto      string
	StatusCode int
	Header     http.Header
	Body       []byte
}

func (*HTTPResponseView) Encode added in v1.1.0

func (v *HTTPResponseView) Encode() []byte

type HTTPView added in v1.1.0

type HTTPView struct {
	Request  *HTTPRequestView
	Response *HTTPResponseView
}

type ImmutableHTTPInterceptor

type ImmutableHTTPInterceptor func(*http.Request, *http.Response)

type ImmutableWebsocketInterceptor

type ImmutableWebsocketInterceptor func(WSDirection, *http.Request, int, []byte)

type MimtOption

type MimtOption struct {
	Enable       bool
	Proxy        string
	CaPath       string
	KeyPath      string
	FakeCertPool struct {
		Capacity     int
		Interval     int
		ExpireSecond int
	}
	// contains filtered or unexported fields
}

type MitmHandler

type MitmHandler interface {
	SetMutableHTTPInterceptor(MutableHTTPInterceptor)
	SetImmutableHTTPInterceptor(ImmutableHTTPInterceptor)
	SetMutableWebsocketInterceptor(MutableWebsocketInterceptor)
	SetImmutableWebsocketInterceptor(ImmutableWebsocketInterceptor)
	HandleMIMT(context.Context, net.Conn) error
	CAPath() string
}

func NewMitmHandler

func NewMitmHandler(opt MimtOption) (MitmHandler, error)

type MutableHTTPInterceptor

type MutableHTTPInterceptor func(*http.Request, HTTPDelegatedInvoker) (*http.Response, error)

type MutableWebsocketInterceptor

type MutableWebsocketInterceptor func(WSDirection, *http.Request, int, []byte, WebsocketDelegatedInvoker) error

type ReqContext

type ReqContext struct {
	// Used for http proxy and sock5 (connect) proxy
	ConnMethod bool
	Host       string
	Port       string
	Addr       string
	Request    *http.Request
}

type ReqContextKey

type ReqContextKey struct{}

type WSDirection

type WSDirection byte
const (
	Send WSDirection = iota
	Receive
)

type WSFlow added in v1.1.0

type WSFlow struct {
	Direction  WSDirection
	Request    *http.Request
	MsgType    int
	FramedData []byte
}

type WebsocketDelegatedInvoker

type WebsocketDelegatedInvoker interface {
	Invoke(int, []byte) error
}

type WebsocketDelegatedInvokerFunc

type WebsocketDelegatedInvokerFunc func(int, []byte) error

func (WebsocketDelegatedInvokerFunc) Invoke

func (f WebsocketDelegatedInvokerFunc) Invoke(t int, data []byte) error

Jump to

Keyboard shortcuts

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