From 3299e1a8472888e0fd04e16a0b85234358f43a62 Mon Sep 17 00:00:00 2001 From: hoelee Date: Wed, 11 Mar 2026 08:51:00 +0800 Subject: [PATCH] feat(botfilter): add CreateConfig --- config.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/config.go b/config.go index 119afc97..f3e59a2f 100644 --- a/config.go +++ b/config.go @@ -39,3 +39,24 @@ type Config struct { LogBlockedRequests bool `json:"logBlockedRequests,omitempty" yaml:"logBlockedRequests,omitempty" toml:"logBlockedRequests,omitempty"` } +// CreateConfig creates the default configuration. The defaults protect common +// public HTTP services without requiring a third-party dependency. +func CreateConfig() *Config { + return &Config{ + StatusCode: 403, + TemporaryBanMinutes: 15, + ScoreThreshold: 100, + ScoreWindowMinutes: 15, + MaxTrackedIPs: 50000, + MaxScoreEventsPerIP: 16, + EmptyUserAgentScore: 40, + MissingAcceptScore: 20, + BlockedUserAgentScore: 80, + BadPathScore: 50, + RandomArticleScore: 15, + NotFoundScore: 40, + FakeBrowserScore: 40, + RandomArticlePatterns: []string{"/content/"}, + } +} +