ENH: added 'matches' to the Ticket(s) and deprecated "custom" constructors for derived *Tickets

pull/4/head
Yaroslav Halchenko 13 years ago
parent ed6daa70bf
commit b52d420575

@ -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

Loading…
Cancel
Save