Browse Source

Fixed: DNSError exeption raised if proxy.host is ip address

main
nibrag 8 years ago
parent
commit
16760a5a06
1 changed files with 14 additions and 1 deletions
  1. +14
    -1
      aiosocks/connector.py

+ 14
- 1
aiosocks/connector.py View File

@@ -39,7 +39,20 @@ class SocksConnector(aiohttp.TCPConnector):
dst = req.host, req.port
exc = None

proxy_hosts = await self._resolve_host(self._proxy.host, self._proxy.port)
# if self._resolver is AsyncResolver and self._proxy.host
# is ip address, then aiodns raise DNSError.
# It's aiohttp bug? Hot fix:
try:
ipaddress.ip_address(self._proxy.host)
proxy_hosts = await self._loop.getaddrinfo(self._proxy.host, self._proxy.port)
family, _, proto, _, address = proxy_hosts[0]

proxy_hosts = ({'hostname': self._proxy.host,
'host': address[0], 'port': address[1],
'family': family, 'proto': proto,
'flags': socket.AI_NUMERICHOST},)
except ValueError:
proxy_hosts = await self._resolve_host(self._proxy.host, self._proxy.port)

for hinfo in proxy_hosts:
try:


Loading…
Cancel
Save