diff --git a/util.go b/util.go new file mode 100644 index 00000000..bc871156 --- /dev/null +++ b/util.go @@ -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 + } +