From e40a8c8ae832504107d2ebdd69903e516c89ca7f Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 10 Jun 2016 11:22:14 +0200 Subject: [PATCH] small code review --- fail2ban/server/filter.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/fail2ban/server/filter.py b/fail2ban/server/filter.py index d0d8f74e..318d8e49 100644 --- a/fail2ban/server/filter.py +++ b/fail2ban/server/filter.py @@ -533,21 +533,17 @@ class Filter(JailThread): # failure-id: fid = fail.get('fid') # ip-address or host: - host = fail.get('ip4') + host = fail.get('ip4') or fail.get('ip6') if host is not None: raw = True else: - host = fail.get('ip6') - if host is not None: - raw = True - else: - host = fail.get('dns') - if host is None: - # if no failure-id also (obscure case, wrong regex), throw error inside getFailID: - if fid is None: - fid = failRegex.getFailID() - host = fid - cidr = IPAddr.CIDR_RAW + host = fail.get('dns') + if host is None: + # if no failure-id also (obscure case, wrong regex), throw error inside getFailID: + if fid is None: + fid = failRegex.getFailID() + host = fid + cidr = IPAddr.CIDR_RAW # if raw - add single ip or failure-id, # otherwise expand host to multiple ips using dns (or ignore it if not valid): if raw: