diff --git a/cache.go b/cache.go index 2cfd88d4..8611acda 100644 --- a/cache.go +++ b/cache.go @@ -62,3 +62,16 @@ func newClientCache(cfg *compiledConfig) *clientCache { } } +func (c *clientCache) isBanned(ip string, now time.Time) cacheResult { + if ip == "" { + return cacheResult{} + } + c.mu.Lock() + defer c.mu.Unlock() + state := c.entries[ip] + if state == nil || !state.banUntil.After(now) { + return cacheResult{} + } + return cacheResult{banned: true, banUntil: state.banUntil} +} +