Merge pull request #1184 from fail2ban/gh-1164-fix

Bugfix for dnsToIp resolver for fqdn with large list of IPs;
pull/1185/head^2
Yaroslav Halchenko 2015-09-09 18:07:26 -04:00
commit 4a53629004
2 changed files with 3 additions and 1 deletions

View File

@ -11,6 +11,7 @@ ver. 0.9.4 (2015/XX/XXX) - wanna-be-released
- Fixes:
* roundcube-auth jail typo for logpath
* Fix dnsToIp resolver for fqdn with large list of IPs (gh-1164)
- New Features:

View File

@ -855,8 +855,9 @@ class DNSUtils:
""" Convert a DNS into an IP address using the Python socket module.
Thanks to Kevin Drapel.
"""
# retrieve ip (todo: use AF_INET6 for IPv6)
try:
return set(socket.gethostbyname_ex(dns)[2])
return set([i[4][0] for i in socket.getaddrinfo(dns, None, socket.AF_INET, 0, socket.IPPROTO_TCP)])
except socket.error, e:
logSys.warning("Unable to find a corresponding IP address for %s: %s"
% (dns, e))