From 7e5d7fde58bec5a1fd09e739fe2f1705e324ce58 Mon Sep 17 00:00:00 2001 From: hoelee Date: Wed, 15 Apr 2026 11:12:00 +0800 Subject: [PATCH] feat(botfilter): matcher.go part 2/5 --- matcher.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/matcher.go b/matcher.go index 4179e366..f83abcfa 100644 --- a/matcher.go +++ b/matcher.go @@ -34,3 +34,19 @@ func inspectRequest(r *http.Request, cfg *compiledConfig) matchResult { return matchResult{points: cfg.BadPathScore, forceBan: true, reason: "blocked extension"} } + result := matchResult{} + if userAgent == "" { + result.points += cfg.EmptyUserAgentScore + result.reason = "empty user-agent" + } + if !hasHeader(r, "Accept") { + result.points += cfg.MissingAcceptScore + result.reason = appendReason(result.reason, "missing accept") + } + if cfg.BrowserValidation && implausibleBrowser(r, userAgent) { + result.points += cfg.FakeBrowserScore + result.reason = appendReason(result.reason, "implausible browser headers") + } + return result +} +