Update elazarl/goproxy

This commit is contained in:
Mikkel Oscar Lyderik Larsen
2017-04-05 23:29:15 +02:00
parent dbcfdb378d
commit b5ce698a68
7 changed files with 186 additions and 76 deletions

View File

@@ -124,10 +124,15 @@ func DstHostIs(host string) ReqConditionFunc {
}
}
// SrcIpIs returns a ReqCondition testing wether the source IP of the request is the given string
func SrcIpIs(ip string) ReqCondition {
// SrcIpIs returns a ReqCondition testing whether the source IP of the request is one of the given strings
func SrcIpIs(ips ...string) ReqCondition {
return ReqConditionFunc(func(req *http.Request, ctx *ProxyCtx) bool {
return strings.HasPrefix(req.RemoteAddr, ip+":")
for _, ip := range ips {
if strings.HasPrefix(req.RemoteAddr, ip+":") {
return true
}
}
return false
})
}