aio-libs/aiodns

can't resolve localhost

wumpus opened this issue · 4 comments

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?

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!

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

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!

Thank you!