feat(botfilter): add clientCache.isBanned

This commit is contained in:
hoelee committed 2026-02-10 16:47:00 +08:00
1 parent b2ac2ce43d
commit d406d7183b
1 file changed
+13
+13
View File
@@ -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}
}