Documentation ¶
Overview ¶
Package goproxy HTTP(S)代理, 支持中间人代理解密HTTPS数据
Index ¶
- func CloneHeader(h http.Header, h2 http.Header)
- func CopyHeader(dst, src http.Header)
- type ConnBuffer
- func (cb *ConnBuffer) BufferReader() *bufio.Reader
- func (cb *ConnBuffer) Header() http.Header
- func (cb *ConnBuffer) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (cb *ConnBuffer) Peek(n int) ([]byte, error)
- func (cb *ConnBuffer) Read(b []byte) (n int, err error)
- func (cb *ConnBuffer) Write(p []byte) (n int, err error)
- func (cb *ConnBuffer) WriteHeader(_ int)
- type Context
- type DefaultDelegate
- func (h *DefaultDelegate) Auth(ctx *Context, rw http.ResponseWriter)
- func (h *DefaultDelegate) BeforeRequest(ctx *Context)
- func (h *DefaultDelegate) BeforeResponse(ctx *Context, resp *http.Response, err error)
- func (h *DefaultDelegate) Connect(ctx *Context, rw http.ResponseWriter)
- func (h *DefaultDelegate) ErrorLog(err error)
- func (h *DefaultDelegate) Finish(ctx *Context)
- func (h *DefaultDelegate) ParentProxy(req *http.Request) (*url.URL, error)
- func (h *DefaultDelegate) WebSocketReceiveMessage(ctx *Context, messageType *int, payload *[]byte)
- func (h *DefaultDelegate) WebSocketSendMessage(ctx *Context, messageType *int, payload *[]byte)
- type Delegate
- type DialContext
- type HeaderPool
- type Option
- func WithClientTrace(t *httptrace.ClientTrace) Option
- func WithDecryptHTTPS(c cert.Cache) Option
- func WithDelegate(delegate Delegate) Option
- func WithDelegatetHTTPS(c cert.Cache, delegate Delegate) Option
- func WithDisableKeepAlive(disableKeepAlive bool) Option
- func WithEnableWebsocketIntercept() Option
- func WithTransport(t *http.Transport) Option
- type Proxy
- type RequestPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneHeader ¶ added in v1.0.1
CloneHeader 深拷贝Header
Types ¶
type ConnBuffer ¶ added in v1.3.3
func NewConnBuffer ¶ added in v1.3.3
func NewConnBuffer(conn net.Conn, buf *bufio.ReadWriter) *ConnBuffer
func (*ConnBuffer) BufferReader ¶ added in v1.3.3
func (cb *ConnBuffer) BufferReader() *bufio.Reader
func (*ConnBuffer) Header ¶ added in v1.3.3
func (cb *ConnBuffer) Header() http.Header
func (*ConnBuffer) Hijack ¶ added in v1.3.3
func (cb *ConnBuffer) Hijack() (net.Conn, *bufio.ReadWriter, error)
func (*ConnBuffer) WriteHeader ¶ added in v1.3.3
func (cb *ConnBuffer) WriteHeader(_ int)
type Context ¶
type Context struct { Req *http.Request Data map[interface{}]interface{} TunnelProxy bool // contains filtered or unexported fields }
Context 代理上下文
func (*Context) WebsocketUrl ¶ added in v1.3.3
type DefaultDelegate ¶
type DefaultDelegate struct {
Delegate
}
DefaultDelegate 默认Handler什么也不做
func (*DefaultDelegate) Auth ¶
func (h *DefaultDelegate) Auth(ctx *Context, rw http.ResponseWriter)
func (*DefaultDelegate) BeforeRequest ¶
func (h *DefaultDelegate) BeforeRequest(ctx *Context)
func (*DefaultDelegate) BeforeResponse ¶
func (h *DefaultDelegate) BeforeResponse(ctx *Context, resp *http.Response, err error)
func (*DefaultDelegate) Connect ¶
func (h *DefaultDelegate) Connect(ctx *Context, rw http.ResponseWriter)
func (*DefaultDelegate) ErrorLog ¶
func (h *DefaultDelegate) ErrorLog(err error)
func (*DefaultDelegate) Finish ¶
func (h *DefaultDelegate) Finish(ctx *Context)
func (*DefaultDelegate) ParentProxy ¶
func (*DefaultDelegate) WebSocketReceiveMessage ¶ added in v1.3.3
func (h *DefaultDelegate) WebSocketReceiveMessage(ctx *Context, messageType *int, payload *[]byte)
WebSockerReceiveMessage websocket接收 消息
func (*DefaultDelegate) WebSocketSendMessage ¶ added in v1.3.3
func (h *DefaultDelegate) WebSocketSendMessage(ctx *Context, messageType *int, payload *[]byte)
WebSocketSendMessage websocket发送消息
type Delegate ¶
type Delegate interface { // Connect 收到客户端连接 Connect(ctx *Context, rw http.ResponseWriter) // Auth 代理身份认证 Auth(ctx *Context, rw http.ResponseWriter) // BeforeRequest HTTP请求前 设置X-Forwarded-For, 修改Header、Body BeforeRequest(ctx *Context) // BeforeResponse 响应发送到客户端前, 修改Header、Body、Status Code BeforeResponse(ctx *Context, resp *http.Response, err error) // WebSocketSendMessage websocket发送消息 WebSocketSendMessage(ctx *Context, messageType *int, p *[]byte) // WebSockerReceiveMessage websocket接收 消息 WebSocketReceiveMessage(ctx *Context, messageType *int, p *[]byte) // ParentProxy 上级代理 ParentProxy(*http.Request) (*url.URL, error) // Finish 本次请求结束 Finish(ctx *Context) // 记录错误信息 ErrorLog(err error) }
type DialContext ¶ added in v1.3.3
type HeaderPool ¶ added in v1.3.3
type HeaderPool struct {
// contains filtered or unexported fields
}
func NewHeaderPool ¶ added in v1.3.3
func NewHeaderPool() *HeaderPool
func (*HeaderPool) Get ¶ added in v1.3.3
func (p *HeaderPool) Get() http.Header
func (*HeaderPool) Put ¶ added in v1.3.3
func (p *HeaderPool) Put(header http.Header)
type Option ¶
type Option func(*options)
func WithClientTrace ¶ added in v1.3.3
func WithClientTrace(t *httptrace.ClientTrace) Option
func WithDecryptHTTPS ¶
WithDecryptHTTPS 中间人代理, 解密HTTPS, 需实现证书缓存接口
func WithDelegatetHTTPS ¶ added in v1.3.3
func WithDisableKeepAlive ¶
WithDisableKeepAlive 连接是否重用
func WithEnableWebsocketIntercept ¶ added in v1.3.3
func WithEnableWebsocketIntercept() Option
WithEnableWebsocketIntercept 拦截websocket
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy 实现了http.Handler接口
type RequestPool ¶ added in v1.3.3
type RequestPool struct {
// contains filtered or unexported fields
}
func (*RequestPool) Get ¶ added in v1.3.3
func (p *RequestPool) Get() *http.Request
func (*RequestPool) Put ¶ added in v1.3.3
func (p *RequestPool) Put(req *http.Request)
Click to show internal directories.
Click to hide internal directories.