From a6183132068d7f222ff8dc3f16dd77171acb11a7 Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Sun, 17 Sep 2006 22:01:14 +0000 Subject: [PATCH] - Added "ignoreip" feature git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@359 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- client/jailreader.py | 3 +++ server/filter.py | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/client/jailreader.py b/client/jailreader.py index 4df4ecc8..635f62d6 100644 --- a/client/jailreader.py +++ b/client/jailreader.py @@ -61,6 +61,7 @@ class JailReader(ConfigReader): ["int", "maxretry", 3], ["int", "maxtime", 600], ["int", "bantime", 600], + ["string", "ignoreip", None], ["string", "filter", ""], ["string", "action", ""]] self.opts = ConfigReader.getOptions(self, self.name, opts) @@ -103,6 +104,8 @@ class JailReader(ConfigReader): stream.append(["set", self.name, "addlogpath", path]) elif opt == "maxretry": stream.append(["set", self.name, "maxretry", self.opts[opt]]) + elif opt == "ignoreip": + stream.append(["set", self.name, "addignoreip", self.opts[opt]]) elif opt == "maxtime": stream.append(["set", self.name, "maxtime", self.opts[opt]]) elif opt == "bantime": diff --git a/server/filter.py b/server/filter.py index 4e5fc8b4..d7467761 100644 --- a/server/filter.py +++ b/server/filter.py @@ -230,8 +230,18 @@ class Filter(JailThread): # @param ip IP address to ignore def addIgnoreIP(self, ip): - logSys.debug("Add " + ip + " to ignore list") - self.ignoreIpList.append(ip) + if DNSUtils.isValidIP(ip): + logSys.debug("Add " + ip + " to ignore list") + self.ignoreIpList.append(ip) + else: + logSys.warn(ip + " is not a valid address") + + def delIgnoreIP(self, ip): + logSys.debug("Remove " + ip + " from ignore list") + self.ignoreIpList.remove(ip) + + def getIgnoreIP(self): + return self.ignoreIpList ## # Check if IP address is in the ignore list.