diff --git a/ChangeLog b/ChangeLog index 9e722608..1978bf8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -69,6 +69,8 @@ TODO: implementing of options resp. other tasks from PR #1346 - `` - PTR reversed representation of IP address - `` - host name of the IP address - `` - interpolates to the corresponding filter group capture `...` + - `` - fully-qualified name of host (the same as `$(hostname -f)`) + - `` - short hostname (the same as `$(uname -n)`) * Allow to use filter options by `fail2ban-regex`, example: fail2ban-regex text.log "sshd[mode=aggressive]" * Samples test case factory extended with filter options - dict in JSON to control diff --git a/fail2ban/server/ipdns.py b/fail2ban/server/ipdns.py index e1aa1920..567a7f7d 100644 --- a/fail2ban/server/ipdns.py +++ b/fail2ban/server/ipdns.py @@ -148,11 +148,8 @@ class DNSUtils: # get it using different ways (a set with names of localhost, hostname, fully qualified): if names is None: names = set(['localhost']) - for hostname in (socket.gethostname, socket.getfqdn): - try: - names |= set([hostname()]) - except Exception as e: # pragma: no cover - logSys.warning("Retrieving own hostnames failed: %s", e) + for fqdn in (False, True): + names.add(DNSUtils.getHostname(fqdn=fqdn)) # cache and return : DNSUtils.CACHE_ipToName.set(key, names) return names