diff --git a/fail2ban/server/filter.py b/fail2ban/server/filter.py index c4f29878..c309bbb2 100644 --- a/fail2ban/server/filter.py +++ b/fail2ban/server/filter.py @@ -458,7 +458,10 @@ class Filter(JailThread): return # Create IP address object ip = IPAddr(ipstr) - + # Avoid exact duplicates + if ip in self.__ignoreIpList: + logSys.warn(" Ignore duplicate %r (%r), already in ignore list", ip, ipstr) + return # log and append to ignore list logSys.debug(" Add %r to ignore list (%r)", ip, ipstr) self.__ignoreIpList.append(ip) diff --git a/fail2ban/tests/servertestcase.py b/fail2ban/tests/servertestcase.py index 0b888407..1d963d0c 100644 --- a/fail2ban/tests/servertestcase.py +++ b/fail2ban/tests/servertestcase.py @@ -441,17 +441,16 @@ class Transmitter(TransmitterBase): self.assertEqual( self.transm.proceed(["set", self.jailName, "addignoreip", value]), (0, [value])) - # Will allow duplicate - #NOTE: Should duplicates be allowed, or silent ignore like logpath? + # Duplicates ignored self.assertEqual( self.transm.proceed(["set", self.jailName, "addignoreip", value]), - (0, [value, value])) + (0, [value])) self.assertEqual( self.transm.proceed(["get", self.jailName, "ignoreip"]), - (0, [value, value])) + (0, [value])) self.assertEqual( self.transm.proceed(["set", self.jailName, "delignoreip", value]), - (0, [value])) + (0, [])) self.assertEqual( self.transm.proceed(["get", self.jailName, "ignoreself"]),