From e4ccbe728633fd12b90e1cf60a13de961ac53442 Mon Sep 17 00:00:00 2001 From: sebres Date: Mon, 24 Apr 2017 21:32:40 +0200 Subject: [PATCH] code review: getHostname can return '' --- fail2ban/server/ipdns.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fail2ban/server/ipdns.py b/fail2ban/server/ipdns.py index 567a7f7d..6ef36888 100644 --- a/fail2ban/server/ipdns.py +++ b/fail2ban/server/ipdns.py @@ -147,9 +147,9 @@ class DNSUtils: names = DNSUtils.CACHE_ipToName.get(key) # get it using different ways (a set with names of localhost, hostname, fully qualified): if names is None: - names = set(['localhost']) - for fqdn in (False, True): - names.add(DNSUtils.getHostname(fqdn=fqdn)) + names = set([ + 'localhost', DNSUtils.getHostname(False), DNSUtils.getHostname(True) + ]) - set(['']) # getHostname can return '' # cache and return : DNSUtils.CACHE_ipToName.set(key, names) return names