MCPcopy
hub / github.com/bettercap/bettercap / shouldProxy

Method shouldProxy

modules/http_proxy/http_proxy_base.go:148–172  ·  view source on GitHub ↗
(req *http.Request)

Source from the content-addressed store, hash-verified

146}
147
148func (p *HTTPProxy) shouldProxy(req *http.Request) bool {
149 hostname := strings.Split(req.Host, ":")[0]
150
151 // check for the whitelist
152 for _, expr := range p.Whitelist {
153 if matched, err := filepath.Match(expr, hostname); err != nil {
154 p.Error("error while using proxy whitelist expression '%s': %v", expr, err)
155 } else if matched {
156 p.Debug("hostname '%s' matched whitelisted element '%s'", hostname, expr)
157 return true
158 }
159 }
160
161 // then the blacklist
162 for _, expr := range p.Blacklist {
163 if matched, err := filepath.Match(expr, hostname); err != nil {
164 p.Error("error while using proxy blacklist expression '%s': %v", expr, err)
165 } else if matched {
166 p.Debug("hostname '%s' matched blacklisted element '%s'", hostname, expr)
167 return false
168 }
169 }
170
171 return true
172}
173
174func (p *HTTPProxy) Configure(address string, proxyPort int, httpPort int, doRedirect bool, scriptPath string,
175 jsToInject string, stripSSL bool) error {

Callers 4

onRequestFilterMethod · 0.95
onResponseFilterMethod · 0.95
TestHTTPProxyShouldProxyFunction · 0.95

Calls 2

ErrorMethod · 0.95
DebugMethod · 0.95

Tested by 2

TestHTTPProxyShouldProxyFunction · 0.76