mirror of https://github.com/fail2ban/fail2ban
RF: expose Actions.banManager (was private)
* needed for testing * later on might get hidden again as a R/O property * makes it more consistent with exposed failManager_tent/expose_banned_ips
parent
db39c7438a
commit
c19e172b4d
|
@ -55,9 +55,9 @@ class Actions(JailThread):
|
||||||
JailThread.__init__(self)
|
JailThread.__init__(self)
|
||||||
## The jail which contains this action.
|
## The jail which contains this action.
|
||||||
self.jail = jail
|
self.jail = jail
|
||||||
self.__actions = list()
|
|
||||||
## The ban manager.
|
## The ban manager.
|
||||||
self.__banManager = BanManager()
|
self.banManager = BanManager()
|
||||||
|
self.__actions = list()
|
||||||
|
|
||||||
##
|
##
|
||||||
# Adds an action.
|
# Adds an action.
|
||||||
|
@ -109,7 +109,7 @@ class Actions(JailThread):
|
||||||
# @param value the time
|
# @param value the time
|
||||||
|
|
||||||
def setBanTime(self, value):
|
def setBanTime(self, value):
|
||||||
self.__banManager.setBanTime(value)
|
self.banManager.setBanTime(value)
|
||||||
logSys.info("Set banTime = %s" % value)
|
logSys.info("Set banTime = %s" % value)
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -118,8 +118,8 @@ class Actions(JailThread):
|
||||||
# @return the time
|
# @return the time
|
||||||
|
|
||||||
def getBanTime(self):
|
def getBanTime(self):
|
||||||
return self.__banManager.getBanTime()
|
return self.banManager.getBanTime()
|
||||||
|
|
||||||
##
|
##
|
||||||
# Main loop.
|
# Main loop.
|
||||||
#
|
#
|
||||||
|
@ -162,7 +162,9 @@ class Actions(JailThread):
|
||||||
aInfo["failures"] = bTicket.getAttempt()
|
aInfo["failures"] = bTicket.getAttempt()
|
||||||
aInfo["time"] = bTicket.getTime()
|
aInfo["time"] = bTicket.getTime()
|
||||||
aInfo["matches"] = "".join(bTicket.getMatches())
|
aInfo["matches"] = "".join(bTicket.getMatches())
|
||||||
if self.__banManager.addBanTicket(bTicket):
|
aInfo["banned_ips"] = ", ".join(self.banManager.getBanList())
|
||||||
|
aInfo["num_banned_ips"] = self.banManager.size()
|
||||||
|
if self.banManager.addBanTicket(bTicket):
|
||||||
logSys.warn("[%s] Ban %s" % (self.jail.getName(), aInfo["ip"]))
|
logSys.warn("[%s] Ban %s" % (self.jail.getName(), aInfo["ip"]))
|
||||||
for action in self.__actions:
|
for action in self.__actions:
|
||||||
action.execActionBan(aInfo)
|
action.execActionBan(aInfo)
|
||||||
|
@ -178,7 +180,7 @@ class Actions(JailThread):
|
||||||
# Unban IP address which are outdated.
|
# Unban IP address which are outdated.
|
||||||
|
|
||||||
def __checkUnBan(self):
|
def __checkUnBan(self):
|
||||||
for ticket in self.__banManager.unBanList(MyTime.time()):
|
for ticket in self.banManager.unBanList(MyTime.time()):
|
||||||
self.__unBan(ticket)
|
self.__unBan(ticket)
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -188,7 +190,7 @@ class Actions(JailThread):
|
||||||
|
|
||||||
def __flushBan(self):
|
def __flushBan(self):
|
||||||
logSys.debug("Flush ban list")
|
logSys.debug("Flush ban list")
|
||||||
for ticket in self.__banManager.flushBanList():
|
for ticket in self.banManager.flushBanList():
|
||||||
self.__unBan(ticket)
|
self.__unBan(ticket)
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -203,6 +205,8 @@ class Actions(JailThread):
|
||||||
aInfo["failures"] = ticket.getAttempt()
|
aInfo["failures"] = ticket.getAttempt()
|
||||||
aInfo["time"] = ticket.getTime()
|
aInfo["time"] = ticket.getTime()
|
||||||
aInfo["matches"] = "".join(ticket.getMatches())
|
aInfo["matches"] = "".join(ticket.getMatches())
|
||||||
|
aInfo["banned_ips"] = ", ".join(self.banManager.getBanList())
|
||||||
|
aInfo["num_banned_ips"] = self.banManager.size()
|
||||||
logSys.warn("[%s] Unban %s" % (self.jail.getName(), aInfo["ip"]))
|
logSys.warn("[%s] Unban %s" % (self.jail.getName(), aInfo["ip"]))
|
||||||
for action in self.__actions:
|
for action in self.__actions:
|
||||||
action.execActionUnban(aInfo)
|
action.execActionUnban(aInfo)
|
||||||
|
@ -216,7 +220,7 @@ class Actions(JailThread):
|
||||||
# @return a list with tuple
|
# @return a list with tuple
|
||||||
|
|
||||||
def status(self):
|
def status(self):
|
||||||
ret = [("Currently banned", self.__banManager.size()),
|
ret = [("Currently banned", self.banManager.size()),
|
||||||
("Total banned", self.__banManager.getBanTotal()),
|
("Total banned", self.banManager.getBanTotal()),
|
||||||
("IP list", self.__banManager.getBanList())]
|
("IP list", self.banManager.getBanList())]
|
||||||
return ret
|
return ret
|
||||||
|
|
Loading…
Reference in New Issue