From 3fcc7cdf36c9bd3501f72f5087da4400fe01e093 Mon Sep 17 00:00:00 2001 From: hoelee Date: Wed, 13 May 2026 13:26:00 +0800 Subject: [PATCH] feat(botfilter): botfilter.go part 1/2 --- botfilter.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/botfilter.go b/botfilter.go index 244391f2..c7197c91 100644 --- a/botfilter.go +++ b/botfilter.go @@ -52,3 +52,20 @@ func (b *botFilter) ServeHTTP(rw http.ResponseWriter, r *http.Request) { return } + match := inspectRequest(r, b.config) + paths := requestPaths(r) + decision := b.cache.observeRequest(ip, requestObservation{ + at: now, + paths: paths, + points: match.points, + forceBan: match.forceBan, + }) + if decision.banned { + reason := match.reason + if reason == "" { + reason = "suspicion score threshold" + } + b.reject(rw, ip, reason, decision) + return + } +