From b52d420575485eaf608977f63547c580d123137b Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Wed, 5 Oct 2011 10:43:59 -0400 Subject: [PATCH] ENH: added 'matches' to the Ticket(s) and deprecated "custom" constructors for derived *Tickets --- server/ticket.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/server/ticket.py b/server/ticket.py index 1443fdb8..7721cfbb 100644 --- a/server/ticket.py +++ b/server/ticket.py @@ -34,15 +34,24 @@ logSys = logging.getLogger("fail2ban") class Ticket: - def __init__(self, ip, time): + def __init__(self, ip, time, matches=None): + """Ticket constructor + + @param ip the IP address + @param time the ban time + @param matches (log) lines caused the ticket + """ + self.__ip = ip self.__time = time self.__attempt = 0 + self.__matches = matches or [] def __str__(self): return "%s: ip=%s time=%s #attempts=%d" % \ (self.__class__, self.__ip, self.__time, self.__attempt) + def setIP(self, value): self.__ip = value @@ -61,11 +70,12 @@ class Ticket: def getAttempt(self): return self.__attempt + def getMatches(self): + return self.__matches + class FailTicket(Ticket): - - def __init__(self, ip, time): - Ticket.__init__(self, ip, time) + pass ## @@ -74,14 +84,4 @@ class FailTicket(Ticket): # This class extends the Ticket class. It is mainly used by the BanManager. class BanTicket(Ticket): - - ## - # Constructor. - # - # Call the Ticket (parent) constructor and initialize default - # values. - # @param ip the IP address - # @param time the ban time - - def __init__(self, ip, time): - Ticket.__init__(self, ip, time) + pass