fix ipv6 check
This commit is contained in:
parent
4b97412569
commit
409f3b053d
1 changed files with 10 additions and 1 deletions
|
@ -80,8 +80,8 @@ QCLASS_IN = 1
|
||||||
|
|
||||||
def detect_ipv6_supprot():
|
def detect_ipv6_supprot():
|
||||||
if 'has_ipv6' in dir(socket):
|
if 'has_ipv6' in dir(socket):
|
||||||
s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
|
|
||||||
try:
|
try:
|
||||||
|
s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
|
||||||
s.connect(('ipv6.google.com', 0))
|
s.connect(('ipv6.google.com', 0))
|
||||||
print('IPv6 support')
|
print('IPv6 support')
|
||||||
return True
|
return True
|
||||||
|
@ -447,6 +447,15 @@ class DNSResolver(object):
|
||||||
if not is_valid_hostname(hostname):
|
if not is_valid_hostname(hostname):
|
||||||
callback(None, Exception('invalid hostname: %s' % hostname))
|
callback(None, Exception('invalid hostname: %s' % hostname))
|
||||||
return
|
return
|
||||||
|
if False:
|
||||||
|
addrs = socket.getaddrinfo(hostname, 0, 0,
|
||||||
|
socket.SOCK_DGRAM, socket.SOL_UDP)
|
||||||
|
if addrs:
|
||||||
|
af, socktype, proto, canonname, sa = addrs[0]
|
||||||
|
logging.debug('DNS resolve %s %s' % (hostname, sa[0]) )
|
||||||
|
self._cache[hostname] = sa[0]
|
||||||
|
callback((hostname, sa[0]), None)
|
||||||
|
return
|
||||||
arr = self._hostname_to_cb.get(hostname, None)
|
arr = self._hostname_to_cb.get(hostname, None)
|
||||||
if not arr:
|
if not arr:
|
||||||
if IPV6_CONNECTION_SUPPORT:
|
if IPV6_CONNECTION_SUPPORT:
|
||||||
|
|
Loading…
Add table
Reference in a new issue