Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gethostbyname defaults to ipv6 #23

Closed
gwillem opened this issue Oct 27, 2016 · 5 comments · Fixed by #118
Closed

gethostbyname defaults to ipv6 #23

gwillem opened this issue Oct 27, 2016 · 5 comments · Fixed by #118

Comments

@gwillem
Copy link

gwillem commented Oct 27, 2016

Not sure if it's a bug or intended behaviour, but it's bitten me and other users (probably #22) of aiohttp since they switched to family=0 per default. Most Linux distro's ship with IPv6 enabled (luckily) but most don't have a IPv6 route set up yet.

Output:

Async: ['2a03:b0c0:2:d0::27d:6001']
Socket: ['188.166.29.234', '2a03:b0c0:2:d0::27d:6001']

Test:

import asyncio
import aiodns
import socket

HOST = 'www.vinyl-lp.com'
FAMILY = 0 
PORT = 80

async def aiodns_gethostbyname():
    resolver = aiodns.DNSResolver()
    resp = await resolver.gethostbyname(HOST, FAMILY)
    print("Async: {}".format(resp.addresses))

def regular_gethostbyname():
    resp = socket.getaddrinfo(HOST, PORT, family=FAMILY, proto=socket.IPPROTO_TCP)
    ips = [x[4][0] for x in resp]
    print("Socket: {}".format(ips))


if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(aiodns_gethostbyname())
    loop.close()

    regular_gethostbyname()
@saghul
Copy link
Contributor

saghul commented Oct 31, 2016

aiodns uses pycares which in turn uses c-ares. Can you check at what level the default is applied?

@dimbleby
Copy link

Per c-ares/c-ares#70

@saghul
Copy link
Contributor

saghul commented Jan 5, 2017

Closing since it needs to be solved upstream.

@saghul saghul closed this as completed Jan 5, 2017
@skrech
Copy link

skrech commented Mar 1, 2022

Hello, I see that in c-ares has closed the issue with introduction of ares_getaddrinfo. Is it possible for aiodns to utilize it?

@saghul
Copy link
Contributor

saghul commented Mar 1, 2022

Possibly, PRs are welcome :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants