Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Support resolving plain DNS PTR records #4921
Node's DNS module currently supports reverse IP lookup with dns.reverse(), which internally uses c-ares' gethostbyaddr(). It works great to look up the registered hostname for IP addresses ("Reverse DNS").
c-ares supports querying and parsing PTR records, and ares_gethostbyaddr() uses ares_parse_ptr_reply internally. It's just not wrapped in the current version of node.
I took on the straightforward work of copying the glue code that wraps ares_query/ares_parse_srv_reply into dns.resolveSrv (SRV record lookup), and use ares_parse_ptr_reply to implement dns.resolvePtr, as seen in this pull request. It returns a simple array of strings containing the returned PTR records.
if i have registered a number of DNS-SD service instances, it can look like:
One caveat: this clears up the use of rrtype in dns.resolve() with rrtype="PTR", but changes the behaviour of resolve(hostname,"PTR",cb). Before, this was using dns.reverse(), so to lookup the hostname for 22.214.171.124, you would do:
@dturing ... yes, the easiest thing would be to rebase and squash just those commits together. If things are out of order, one easy thing to do would be a