mirror of https://github.com/fail2ban/fail2ban
amend to fe06ffca71e9054b21b93237c40c0c53478a19df: small optimization using already known IP family
parent
fe06ffca71
commit
9d15a792a5
|
@ -564,7 +564,7 @@ class Filter(JailThread):
|
||||||
dateTimeMatch = self.dateDetector.getTime(timeText, tupleLine[3])
|
dateTimeMatch = self.dateDetector.getTime(timeText, tupleLine[3])
|
||||||
|
|
||||||
if dateTimeMatch is None:
|
if dateTimeMatch is None:
|
||||||
logSys.error("findFailure failed to parse timeText: " + timeText)
|
logSys.error("findFailure failed to parse timeText: %s", timeText)
|
||||||
date = self.__lastDate
|
date = self.__lastDate
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -621,10 +621,16 @@ class Filter(JailThread):
|
||||||
# failure-id:
|
# failure-id:
|
||||||
fid = fail.get('fid')
|
fid = fail.get('fid')
|
||||||
# ip-address or host:
|
# ip-address or host:
|
||||||
host = fail.get('ip4') or fail.get('ip6')
|
host = fail.get('ip4')
|
||||||
if host is not None:
|
if host is not None:
|
||||||
|
cidr = IPAddr.FAM_IPv4
|
||||||
raw = True
|
raw = True
|
||||||
else:
|
else:
|
||||||
|
host = fail.get('ip6')
|
||||||
|
if host is not None:
|
||||||
|
cidr = IPAddr.FAM_IPv6
|
||||||
|
raw = True
|
||||||
|
if host is None:
|
||||||
host = fail.get('dns')
|
host = fail.get('dns')
|
||||||
if host is None:
|
if host is None:
|
||||||
# if no failure-id also (obscure case, wrong regex), throw error inside getFailID:
|
# if no failure-id also (obscure case, wrong regex), throw error inside getFailID:
|
||||||
|
@ -639,13 +645,9 @@ class Filter(JailThread):
|
||||||
# check host equal failure-id, if not - failure with complex id:
|
# check host equal failure-id, if not - failure with complex id:
|
||||||
if fid is not None and fid != host:
|
if fid is not None and fid != host:
|
||||||
ip = IPAddr(fid, IPAddr.CIDR_RAW)
|
ip = IPAddr(fid, IPAddr.CIDR_RAW)
|
||||||
failList.append([failRegexIndex, ip, date,
|
ips = [ip]
|
||||||
failRegex.getMatchedLines(), fail])
|
|
||||||
if not self.checkAllRegex:
|
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
ips = DNSUtils.textToIp(host, self.__useDns)
|
ips = DNSUtils.textToIp(host, self.__useDns)
|
||||||
if ips:
|
|
||||||
for ip in ips:
|
for ip in ips:
|
||||||
failList.append([failRegexIndex, ip, date,
|
failList.append([failRegexIndex, ip, date,
|
||||||
failRegex.getMatchedLines(), fail])
|
failRegex.getMatchedLines(), fail])
|
||||||
|
|
Loading…
Reference in New Issue