Versions in this module Expand all Collapse all v0 v0.6.0 Mar 4, 2024 v0.5.0 Mar 4, 2024 Changes in this version + const ClientToServer + const ConnectAccept + const ConnectHTTPMitm + const ConnectHijack + const ConnectMitm + const ConnectProxyAuthHijack + const ConnectReject + const ContentTypeHtml + const ContentTypeText + const ServerToClient + var CA_CERT = []byte(...) + var CA_KEY = []byte(...) + var GoproxyCa = tls.X509KeyPair(CA_CERT, CA_KEY) + var HTTPMitmConnect = &ConnectAction + var MitmConnect = &ConnectAction + var OkConnect = &ConnectAction + var RejectConnect = &ConnectAction + func NewResponse(r *http.Request, contentType string, status int, body string) *http.Response + func TLSConfigFromCA(ca *tls.Certificate) func(host string, ctx *ProxyCtx) (*tls.Config, error) + func TextResponse(r *http.Request, text string) *http.Response + type CertStorage interface + Fetch func(hostname string, gen func() (*tls.Certificate, error)) (*tls.Certificate, error) + type ConnectAction struct + Action ConnectActionLiteral + Hijack func(req *http.Request, client net.Conn, ctx *ProxyCtx) + TLSConfig func(host string, ctx *ProxyCtx) (*tls.Config, error) + type ConnectActionLiteral int + type CounterEncryptorRand struct + func NewCounterEncryptorRandFromKey(key interface{}, seed []byte) (r CounterEncryptorRand, err error) + func (c *CounterEncryptorRand) Read(b []byte) (n int, err error) + func (c *CounterEncryptorRand) Seed(b []byte) + type Direction int8 + type FuncHttpsHandler func(host string, ctx *ProxyCtx) (*ConnectAction, string) + var AlwaysMitm FuncHttpsHandler = func(host string, ctx *ProxyCtx) (*ConnectAction, string) { ... } + var AlwaysReject FuncHttpsHandler = func(host string, ctx *ProxyCtx) (*ConnectAction, string) { ... } + func (f FuncHttpsHandler) HandleConnect(host string, ctx *ProxyCtx) (*ConnectAction, string) + type FuncReqHandler func(req *http.Request, ctx *ProxyCtx) (*http.Request, *http.Response) + func (f FuncReqHandler) Handle(req *http.Request, ctx *ProxyCtx) (*http.Request, *http.Response) + type FuncRespHandler func(resp *http.Response, ctx *ProxyCtx) *http.Response + func (f FuncRespHandler) Handle(resp *http.Response, ctx *ProxyCtx) *http.Response + type HttpsHandler interface + HandleConnect func(req string, ctx *ProxyCtx) (*ConnectAction, string) + type Logger interface + Printf func(format string, v ...interface{}) + type ProxyConds struct + func (pcond *ProxyConds) Do(h RespHandler) + func (pcond *ProxyConds) DoFunc(f func(resp *http.Response, ctx *ProxyCtx) *http.Response) + type ProxyCtx struct + Error error + Proxy *ProxyHttpServer + Req *http.Request + Resp *http.Response + RoundTripper RoundTripper + Session int64 + UserData interface{} + func (ctx *ProxyCtx) Charset() string + func (ctx *ProxyCtx) Logf(msg string, argv ...interface{}) + func (ctx *ProxyCtx) RoundTrip(req *http.Request) (*http.Response, error) + func (ctx *ProxyCtx) Warnf(msg string, argv ...interface{}) + type ProxyHttpServer struct + CertStore CertStorage + ConnectDial func(network string, addr string) (net.Conn, error) + ConnectDialWithReq func(req *http.Request, network string, addr string) (net.Conn, error) + KeepDestinationHeaders bool + KeepHeader bool + Logger Logger + NonproxyHandler http.Handler + Tr *http.Transport + Verbose bool + func NewProxyHttpServer() *ProxyHttpServer + func (proxy *ProxyHttpServer) AddWebSocketHandler(...) + func (proxy *ProxyHttpServer) NewConnectDialToProxy(https_proxy string) func(network, addr string) (net.Conn, error) + func (proxy *ProxyHttpServer) NewConnectDialToProxyWithHandler(https_proxy string, connectReqHandler func(req *http.Request)) func(network, addr string) (net.Conn, error) + func (proxy *ProxyHttpServer) OnRequest(conds ...ReqCondition) *ReqProxyConds + func (proxy *ProxyHttpServer) OnResponse(conds ...RespCondition) *ProxyConds + func (proxy *ProxyHttpServer) ServeHTTP(w http.ResponseWriter, r *http.Request) + type ReqCondition interface + HandleReq func(req *http.Request, ctx *ProxyCtx) bool + func SrcIpIs(ips ...string) ReqCondition + type ReqConditionFunc func(req *http.Request, ctx *ProxyCtx) bool + var IsLocalHost ReqConditionFunc = func(req *http.Request, ctx *ProxyCtx) bool { ... } + func DstHostIs(host string) ReqConditionFunc + func Not(r ReqCondition) ReqConditionFunc + func ReqHostIs(hosts ...string) ReqConditionFunc + func ReqHostMatches(regexps ...*regexp.Regexp) ReqConditionFunc + func UrlHasPrefix(prefix string) ReqConditionFunc + func UrlIs(urls ...string) ReqConditionFunc + func UrlMatches(re *regexp.Regexp) ReqConditionFunc + func (c ReqConditionFunc) HandleReq(req *http.Request, ctx *ProxyCtx) bool + func (c ReqConditionFunc) HandleResp(resp *http.Response, ctx *ProxyCtx) bool + type ReqHandler interface + Handle func(req *http.Request, ctx *ProxyCtx) (*http.Request, *http.Response) + type ReqProxyConds struct + func (pcond *ReqProxyConds) Do(h ReqHandler) + func (pcond *ReqProxyConds) DoFunc(f func(req *http.Request, ctx *ProxyCtx) (*http.Request, *http.Response)) + func (pcond *ReqProxyConds) HandleConnect(h HttpsHandler) + func (pcond *ReqProxyConds) HandleConnectFunc(f func(host string, ctx *ProxyCtx) (*ConnectAction, string)) + func (pcond *ReqProxyConds) HijackConnect(f func(req *http.Request, client net.Conn, ctx *ProxyCtx)) + type RespCondition interface + HandleResp func(resp *http.Response, ctx *ProxyCtx) bool + func ContentTypeIs(typ string, types ...string) RespCondition + func StatusCodeIs(codes ...int) RespCondition + type RespConditionFunc func(resp *http.Response, ctx *ProxyCtx) bool + func (c RespConditionFunc) HandleResp(resp *http.Response, ctx *ProxyCtx) bool + type RespHandler interface + Handle func(resp *http.Response, ctx *ProxyCtx) *http.Response + func HandleBytes(f func(b []byte, ctx *ProxyCtx) []byte) RespHandler + type RoundTripper interface + RoundTrip func(req *http.Request, ctx *ProxyCtx) (*http.Response, error) + type RoundTripperFunc func(req *http.Request, ctx *ProxyCtx) (*http.Response, error) + func (f RoundTripperFunc) RoundTrip(req *http.Request, ctx *ProxyCtx) (*http.Response, error)