Browse Source

fix ipv6 check

dev
BreakWa11 9 years ago
parent
commit
409f3b053d
  1. 11
      shadowsocks/asyncdns.py

11
shadowsocks/asyncdns.py

@ -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…
Cancel
Save