Add periodic cleanup job for DecayMap (#8) (#158)

* Add periodic cleanup job for DecayMap

see https://github.com/TecharoHQ/anubis/issues/8

* Refactor: Improve DecayMap cleanup tests and add Len method

- Refactored DecayMap cleanup tests to use the new Len method
  for more precise assertions.
- Added a Len method to DecayMap to retrieve the number of
  entries.
- Simplified conditional checks in Get method.

* chore(changelog): add entry

* fix(tests): Use Impl.expire for decaymap cleanup

Signed-off-by: Jason Cameron <git@jasoncameron.dev>

---------

Signed-off-by: Jason Cameron <git@jasoncameron.dev>
This commit is contained in:
Jason Cameron 2025-03-29 23:24:06 -04:00 committed by GitHub
parent 052316ba25
commit 0f41388bd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 70 additions and 1 deletions

View file

@ -529,3 +529,7 @@ func (s *Server) checkRemoteAddress(b policy.Bot, addr net.IP) bool {
return ok
}
func (s *Server) CleanupDecayMap() {
s.DNSBLCache.Cleanup()
}