Skip to content

Commit

Permalink
Update caddywaf.go
Browse files Browse the repository at this point in the history
rate limit options shown while starting fix
  • Loading branch information
fabriziosalmi authored Jan 7, 2025
1 parent 557e298 commit 853a241
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions caddywaf.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ type requestCounter struct {

// RateLimit struct
type RateLimit struct {
Requests int `json:"requests"`
Window time.Duration `json:"window"`
Requests int `json:"requests"`
Window time.Duration `json:"window"`
CleanupInterval time.Duration `json:"cleanup_interval"`
}

Expand Down Expand Up @@ -836,6 +836,17 @@ func (m *Middleware) Provision(ctx caddy.Context) error {
zap.Int("anomaly_threshold", m.AnomalyThreshold),
)

// Log rate limit configuration if enabled
if m.RateLimit.Requests > 0 {
m.logger.Info("Rate limit configuration",
zap.Int("requests", m.RateLimit.Requests),
zap.Duration("window", m.RateLimit.Window),
zap.Duration("cleanup_interval", m.RateLimit.CleanupInterval),
)
} else {
m.logger.Info("Rate limiting is disabled")
}

// Initialize rate limiter if configured
if m.RateLimit.Requests > 0 {
m.logger.Debug("Initializing rate limiter",
Expand Down

0 comments on commit 853a241

Please sign in to comment.