From 6d6acb075a7eba7c8f699829147d95648e147ebb Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Mon, 29 Jan 2007 21:46:59 +0000 Subject: [PATCH] - Added IP list in "status ". Thanks to Eric Gerbier git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@535 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- CHANGELOG | 1 + README | 2 +- client/beautifier.py | 10 ++++++---- server/actions.py | 4 ++-- server/banmanager.py | 12 ++++++++++++ server/failmanager.py | 12 ++++++++++++ server/filter.py | 3 ++- 7 files changed, 36 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2eb5540c..5181fd21 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ ver. 0.7.7 (2007/??/??) - Added file support to fail2ban-regex. Benchmark feature has been removed - Added cacti script and template. +- Added IP list in "status ". Thanks to Eric Gerbier ver. 0.7.6 (2007/01/04) - beta ---------- diff --git a/README b/README index 6ff995c2..11d42c37 100644 --- a/README +++ b/README @@ -73,7 +73,7 @@ Tom Pike, Iain Lea, Andrey G. Grozin, Yaroslav Halchenko, Jonathan Kamens, Stephen Gildea, Markus Hoffmann, Mark Edgington, Patrick Börjesson, kojiro, zugeschmiert, Tyler, Nick Munger, Christoph Haas, Justin Shore, Joël Bertrand, -René Berber, mEDI, Axel Thimm +René Berber, mEDI, Axel Thimm, Eric Gerbier License: -------- diff --git a/client/beautifier.py b/client/beautifier.py index c017c5a2..e6eb6c27 100644 --- a/client/beautifier.py +++ b/client/beautifier.py @@ -70,11 +70,13 @@ class Beautifier: if len(inC) > 1: msg = "Status for the jail: " + inC[1] + "\n" msg = msg + "|- " + response[0][0] + "\n" - msg = msg + "| |- " + response[0][1][0][0] + ":\t\t" + `response[0][1][0][1]` + "\n" - msg = msg + "| `- " + response[0][1][1][0] + ":\t\t" + `response[0][1][1][1]` + "\n" + msg = msg + "| |- " + response[0][1][0][0] + ":\t" + `response[0][1][0][1]` + "\n" + msg = msg + "| | `- " + response[0][1][2][0] + ":\t" + `response[0][1][2][1]` + "\n" + msg = msg + "| `- " + response[0][1][1][0] + ":\t" + `response[0][1][1][1]` + "\n" msg = msg + "`- " + response[1][0] + "\n" - msg = msg + " |- " + response[1][1][0][0] + ":\t\t" + `response[1][1][0][1]` + "\n" - msg = msg + " `- " + response[1][1][1][0] + ":\t\t" + `response[1][1][1][1]` + msg = msg + " |- " + response[1][1][0][0] + ":\t" + `response[1][1][0][1]` + "\n" + msg = msg + " | `- " + response[1][1][2][0] + ":\t" + `response[1][1][2][1]` + "\n" + msg = msg + " `- " + response[1][1][1][0] + ":\t" + `response[1][1][1][1]` else: msg = "Status\n" msg = msg + "|- " + response[0][0] + ":\t" + `response[0][1]` + "\n" diff --git a/server/actions.py b/server/actions.py index c5f9d25b..a18d2f4f 100644 --- a/server/actions.py +++ b/server/actions.py @@ -189,6 +189,6 @@ class Actions(JailThread): def status(self): ret = [("Currently banned", self.__banManager.size()), - ("Total banned", self.__banManager.getBanTotal())] + ("Total banned", self.__banManager.getBanTotal()), + ("IP list", self.__banManager.getBanList())] return ret - \ No newline at end of file diff --git a/server/banmanager.py b/server/banmanager.py index dd7791d7..140a50f0 100644 --- a/server/banmanager.py +++ b/server/banmanager.py @@ -100,7 +100,19 @@ class BanManager: return self.__banTotal finally: self.__lock.release() + + ## + # Returns a copy of the IP list. + # + # @return IP list + def getBanList(self): + try: + self.__lock.acquire() + return list(self.__banList) + finally: + self.__lock.release() + ## # Create a ban ticket. # diff --git a/server/failmanager.py b/server/failmanager.py index 2a43c9f1..bbe64503 100644 --- a/server/failmanager.py +++ b/server/failmanager.py @@ -77,6 +77,18 @@ class FailManager: finally: self.__lock.release() + ## + # Returns a copy of the IP list. + # + # @return IP list + + def getBanList(self): + try: + self.__lock.acquire() + return list(self.__failList) + finally: + self.__lock.release() + def addFailure(self, ticket): self.__lock.acquire() ip = ticket.getIP() diff --git a/server/filter.py b/server/filter.py index ed63299d..f4705562 100644 --- a/server/filter.py +++ b/server/filter.py @@ -463,7 +463,8 @@ class Filter(JailThread): def status(self): ret = [("Currently failed", self.failManager.size()), - ("Total failed", self.failManager.getFailTotal())] + ("Total failed", self.failManager.getFailTotal()), + ("IP List", self.failManager.getBanList())] return ret