aio-libs / aiodns

Simple DNS resolver for asyncio
https://pypi.python.org/pypi/aiodns
MIT License
532 stars 69 forks source link

can't resolve localhost #17

Closed wumpus closed 8 years ago

wumpus commented 8 years ago

I'm using aiodns and was surprised that it could not resolve localhost. Now maybe I shouldn't be surprised, after all Unix has always been a little bit weird about combining looking at /etc/hosts with a dns resolver.

Recommend: mentioning this in the docs?

saghul commented 8 years ago

Hi! What kind of query are you doing? A or AAAA I suppose. I know c-ares reads /etc/hosts but I don't know if it uses that data when doing an A or AAAA query. If you find out a documentation PR would be more than welcome!

wumpus commented 8 years ago

It's an A query. strace says that no one is opening /etc/hosts in my process.

saghul commented 8 years ago

Hi @wumpus! I just released aiodns 1.1.0, which contains a gethostbyname function, which will check /etc/hosts before making an actual DNS query: https://github.com/saghul/aiodns#api

It would be better to have a proper getaddrinfo equivalent, but c-ares (what aiodns uses as the backend) doesn't provide it.

Cheers!

wumpus commented 8 years ago

Thank you!