feat(botfilter): add clientCache.isBanned

This commit is contained in:
hoelee committed 2026-02-11 16:47:00 +08:00
1 parent 598618c00a
commit 06a8ccb0d6
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}
}