Don't resolve AAAA records if there is no dnspython nor IPv6 support

If system doesn't has IPv6 support or dnspython package, socket.getaddrinfo 
with AF_INET6 flag return weird IP info for requested host, making SleekXMPP 
crush with more weird error.
This commit is contained in:
Alexander Shorin 2013-07-29 14:21:46 +04:00
parent d439c4f215
commit 556e4bd74d

View File

@ -202,6 +202,9 @@ def get_AAAA(host, resolver=None):
# If not using dnspython, attempt lookup using the OS level
# getaddrinfo() method.
if resolver is None:
if not socket.has_ipv6:
log.debug("Unable to query %s for AAAA records: IPv6 is not supported", host)
return []
try:
recs = socket.getaddrinfo(host, None, socket.AF_INET6,
socket.SOCK_STREAM)