Merge pull request #1904 from sebres/no-dup-ignoreip-fix-1900

Avoid exact duplicates by addIgnoreIP (closes gh-1900)
pull/1913/head
Serg G. Brester 7 years ago committed by GitHub
commit 32deb828a1

@ -458,7 +458,10 @@ class Filter(JailThread):
return return
# Create IP address object # Create IP address object
ip = IPAddr(ipstr) 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 # log and append to ignore list
logSys.debug(" Add %r to ignore list (%r)", ip, ipstr) logSys.debug(" Add %r to ignore list (%r)", ip, ipstr)
self.__ignoreIpList.append(ip) self.__ignoreIpList.append(ip)

@ -441,17 +441,16 @@ class Transmitter(TransmitterBase):
self.assertEqual( self.assertEqual(
self.transm.proceed(["set", self.jailName, "addignoreip", value]), self.transm.proceed(["set", self.jailName, "addignoreip", value]),
(0, [value])) (0, [value]))
# Will allow duplicate # Duplicates ignored
#NOTE: Should duplicates be allowed, or silent ignore like logpath?
self.assertEqual( self.assertEqual(
self.transm.proceed(["set", self.jailName, "addignoreip", value]), self.transm.proceed(["set", self.jailName, "addignoreip", value]),
(0, [value, value])) (0, [value]))
self.assertEqual( self.assertEqual(
self.transm.proceed(["get", self.jailName, "ignoreip"]), self.transm.proceed(["get", self.jailName, "ignoreip"]),
(0, [value, value])) (0, [value]))
self.assertEqual( self.assertEqual(
self.transm.proceed(["set", self.jailName, "delignoreip", value]), self.transm.proceed(["set", self.jailName, "delignoreip", value]),
(0, [value])) (0, []))
self.assertEqual( self.assertEqual(
self.transm.proceed(["get", self.jailName, "ignoreself"]), self.transm.proceed(["get", self.jailName, "ignoreself"]),

Loading…
Cancel
Save