From 9fe86bc37929a53d8404acb8b7678ca9fa1a84b3 Mon Sep 17 00:00:00 2001 From: hoelee Date: Wed, 13 May 2026 15:40:00 +0800 Subject: [PATCH] feat(botfilter): add botFilter.ServeHTTP --- botfilter.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 + } +