feat(botfilter): cache.go part 2/5

This commit is contained in:
hoelee committed 2026-02-17 09:58:00 +08:00
1 parent f9cc4181b7
commit 6f09675ff9
1 file changed
+10
+10
View File
@@ -87,3 +87,13 @@ func (c *clientCache) observeRequest(ip string, observation requestObservation)
c.operations++
c.cleanupLocked(observation.at)
state := c.entries[ip]
if state != nil && state.banUntil.After(observation.at) {
return cacheResult{banned: true, banUntil: state.banUntil}
}
if state == nil {
c.ensureCapacityLocked(observation.at)
state = &clientState{}
c.entries[ip] = state
}