manually added attempts inform the observer module (take the known ban-count of bad IPs into account);

closes gh-3845
pull/3607/head
sebres 2024-10-08 13:34:19 +02:00
parent 89970d2e3e
commit 0bf1106d72
2 changed files with 9 additions and 0 deletions

View File

@ -482,6 +482,9 @@ class Filter(JailThread):
# Perform the ban if this attempt is resulted to:
if attempts >= self.failManager.getMaxRetry():
self.performBan(ip)
# report to observer - failure was found, for possibly increasing of it retry counter (asynchronous)
if Observers.Main is not None:
Observers.Main.add('failureFound', self.jail, ticket)
return 1

View File

@ -559,6 +559,12 @@ class BanTimeIncrDB(LogCaptureTestCase):
self.assertEqual(restored_tickets[1].getBanTime(), -1)
self.assertEqual(restored_tickets[1].getBanCount(), 1)
self.pruneLog('[test-phase 2] manually attempt must inform observer')
jail.filter.addAttempt(ip)
obs.wait_empty(5)
self.assertLogged("Observer: failure found %s" % ip,
"Found %s, bad" % ip, wait=True)
# stop observer
obs.stop()