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
# 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)

@ -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"]),

Loading…
Cancel
Save