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

This commit is contained in:
hoelee committed 2026-02-11 09:58:00 +08:00
1 parent afdf4db520
commit 618122a6fb
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
}