| 146 | } |
| 147 | |
| 148 | func (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 | |
| 174 | func (p *HTTPProxy) Configure(address string, proxyPort int, httpPort int, doRedirect bool, scriptPath string, |
| 175 | jsToInject string, stripSSL bool) error { |