diff --git a/config.go b/config.go index 5345ff88..e82542a9 100644 --- a/config.go +++ b/config.go @@ -88,3 +88,19 @@ func compileConfig(input *Config) (*compiledConfig, error) { cfg.BlockedExtensions = append([]string(nil), input.BlockedExtensions...) cfg.RandomArticlePatterns = append([]string(nil), input.RandomArticlePatterns...) + defaults := CreateConfig() + applyDefaults(&cfg, defaults) + + if cfg.StatusCode < 400 || cfg.StatusCode > 599 { + return nil, fmt.Errorf("botfilter: statusCode must be between 400 and 599") + } + if cfg.TemporaryBanMinutes <= 0 { + return nil, fmt.Errorf("botfilter: temporaryBanMinutes must be greater than zero") + } + if cfg.ScoreThreshold <= 0 || cfg.ScoreWindowMinutes <= 0 { + return nil, fmt.Errorf("botfilter: scoreThreshold and scoreWindowMinutes must be greater than zero") + } + if cfg.MaxTrackedIPs <= 0 || cfg.MaxScoreEventsPerIP <= 0 { + return nil, fmt.Errorf("botfilter: maxTrackedIPs and maxScoreEventsPerIP must be greater than zero") + } +