aio-libs / aiodns

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

How can i get absolute domains? #28

Closed kotyara1005 closed 5 years ago

kotyara1005 commented 7 years ago

When i use dig i obtain absolute domain names:

;; ANSWER SECTION: google.com. 5 IN NS ns1.google.com. google.com. 5 IN NS ns3.google.com. google.com. 5 IN NS ns4.google.com. google.com. 5 IN NS ns2.google.com.

But aiodns gives me relative domains: [ares_query_ns_result(host='ns3.google.com', ttl=None), ares_query_ns_result(host='ns4.google.com', ttl=None), ares_query_ns_result(host='ns2.google.com', ttl=None), ares_query_ns_result(host='ns1.google.com', ttl=None)]

Is the way to get true data exists?

saghul commented 7 years ago

I'm not sure I understand, aiodns gives you the same thing (module the TTL, which I think I made available in a newer pycares release) so how would you like to see the results?

kotyara1005 commented 7 years ago

I mean that aiodns or pycares strip trailing dot in domain name. It's not right, "ns1.google.com" and "ns1.google.com." are different domains.

saghul commented 7 years ago

The dot is not stripped by those libraries, it must be c-ares, I guess. You can try to compile c-ares and use their adig tool to see what it returns exactly.

saghul commented 7 years ago

@ioc32 perhaps you can help here mate?

ioc32 commented 7 years ago

It looks like aiodns/c-ares simply return unqualified domain names. This is, they return a domain that it's not fully qualified or complete up to the top of the DNS namespace (the root, ".").

ns1.google.com and ns1.google.com. don't have to be the same domain necessarily, but they will indeed be the same pretty much most of the time. For most user oriented DNS tools it is safe to strip the last zone separator (".").

If the fact that labels returned by aiodns are unqualified is a problem and you need to programmatically fully qualify them in the standard DNS root, use your favorite DNS library to canonicalise them before querying them*.

If you simply need to print them (you're not parsing the string and turning it into a domain object) perhaps appending a trailing dot would suffice?

On May 6, 2017 10:44 AM, "Saúl Ibarra Corretgé" notifications@github.com wrote:

@ioc32 https://github.com/ioc32 perhaps you can help here mate?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/saghul/aiodns/issues/28#issuecomment-299625439, or mute the thread https://github.com/notifications/unsubscribe-auth/ABGQrUTe3O8u07WTXyxu1QmQmU4YfyWoks5r3DL8gaJpZM4NEUn4 .