MCPcopy
hub / github.com/bettercap/bettercap / NewHTTPProxy

Function NewHTTPProxy

modules/http_proxy/http_proxy_base.go:77–109  ·  view source on GitHub ↗
(s *session.Session, tag string)

Source from the content-addressed store, hash-verified

75}
76
77func NewHTTPProxy(s *session.Session, tag string) *HTTPProxy {
78 p := &HTTPProxy{
79 Name: "http.proxy",
80 Proxy: goproxy.NewProxyHttpServer(),
81 Sess: s,
82 Stripper: NewSSLStripper(s, false),
83 isTLS: false,
84 doRedirect: true,
85 Server: nil,
86 Blacklist: make([]string, 0),
87 Whitelist: make([]string, 0),
88 tag: session.AsTag(tag),
89 }
90
91 p.Proxy.Verbose = false
92 p.Proxy.Logger = dummyLogger{p}
93
94 p.Proxy.NonproxyHandler = http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
95 if p.doProxy(req) {
96 if !p.isTLS {
97 req.URL.Scheme = "http"
98 }
99 req.URL.Host = req.Host
100 p.Proxy.ServeHTTP(w, req)
101 }
102 })
103
104 p.Proxy.OnRequest().HandleConnect(goproxy.AlwaysMitm)
105 p.Proxy.OnRequest().DoFunc(p.onRequestFilter)
106 p.Proxy.OnResponse().DoFunc(p.onResponseFilter)
107
108 return p
109}
110
111func (p *HTTPProxy) Debug(format string, args ...interface{}) {
112 p.Sess.Events.Log(log.DEBUG, p.tag+format, args...)

Callers 8

NewHttpsProxyFunction · 0.92
NewHttpProxyFunction · 0.85
TestHTTPProxyDoProxyFunction · 0.85
TestHTTPProxyShouldProxyFunction · 0.85

Calls 5

doProxyMethod · 0.95
AsTagFunction · 0.92
NewSSLStripperFunction · 0.85
OnRequestMethod · 0.45
OnResponseMethod · 0.45

Tested by 6

TestHTTPProxyDoProxyFunction · 0.68
TestHTTPProxyShouldProxyFunction · 0.68