feat(botfilter): add clientIP
This commit is contained in:
1 parent
aaa6f82011
commit
e12d44de05
1 file changed
+17
@@ -0,0 +1,17 @@
|
||||
package botfilter
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
"net/netip"
|
||||
"net/url"
|
||||
pathpkg "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func clientIP(r *http.Request, cfg *compiledConfig) netip.Addr {
|
||||
remote := parseRemoteAddress(r.RemoteAddr)
|
||||
if cfg.clientIPHeader == "" || !addressInPrefixes(remote, cfg.trustedProxies) {
|
||||
return remote
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user