feat(botfilter): add clientCache.isBanned
This commit is contained in:
1 parent
598618c00a
commit
06a8ccb0d6
1 file changed
+13
@@ -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}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user