Skip to content

Commit

Permalink
Added in while loop to process the Fail Manager after the requested b…
Browse files Browse the repository at this point in the history
…anned IP was added to its queue. This solves the issue of needing to touch the log file that is being monitored to get the IP to be banned accordingly. Added in import of FailManagerEmpty exception class.
  • Loading branch information
engeset authored and yarikoptic committed Nov 6, 2012
1 parent f14c7ae commit 2d672d1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL"

from failmanager import FailManagerEmpty
from failmanager import FailManager
from ticket import FailTicket
from jailthread import JailThread
Expand Down Expand Up @@ -224,6 +225,14 @@ def addBannedIP(self, ip):
for i in xrange(self.failManager.getMaxRetry()):
self.failManager.addFailure(FailTicket(ip, unixTime))

# Perform the banning of the IP now.
try:
while True:
ticket = self.failManager.toBan()
self.jail.putFailTicket(ticket)
except FailManagerEmpty:
self.failManager.cleanup(MyTime.time())

return ip

##
Expand Down

0 comments on commit 2d672d1

Please sign in to comment.