diff --git a/botfilter.go b/botfilter.go index cad192cc..244391f2 100644 --- a/botfilter.go +++ b/botfilter.go @@ -39,3 +39,16 @@ func New(_ context.Context, next http.Handler, config *Config, name string) (htt }, nil } +func (b *botFilter) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + now := time.Now() + addr := clientIP(r, b.config) + ip := addressString(addr) + if addressInPrefixes(addr, b.config.whitelist) { + b.next.ServeHTTP(rw, r) + return + } + if existing := b.cache.isBanned(ip, now); existing.banned { + b.reject(rw, ip, "temporary ban", existing) + return + } +