Kitz Forum

Chat => Tech Chat => Topic started by: Weaver on July 21, 2018, 11:26:21 AM

Title: User of dns-api.org PTR lookup over http service broken
Post by: Weaver on July 21, 2018, 11:26:21 AM
Why is http://dns-api.org/PTR/8.8.8.8 broken? I use the dns-api.org free DNS query over http services and for example http://dns-api.org/AAAA/dns-api.org works. But with a PTR lookup I just get an NXDOMAIN result all the time.
Title: Re: dns-api.org PTR lookup over http service broken
Post by: johnson on July 21, 2018, 12:18:56 PM
Have never used this service but from this github page:

https://github.com/skx/dns-api-go

Quote
PTR (reverse-DNS) requests must be submitted in reverse-format, for example:

    https://dns-api.org/ptr/100.183.9.176.in-addr.arpa.
    https://dns-api.org/ptr/0.0.1.0.0.0.0.0.0.0.0.0.0.0.0.0.3.8.0.6.1.5.1.0.8.f.4.0.1.0.a.2.ip6.arpa.

I'm not sure what special sauce ".in-addr.arpa" adds or if I'm even reading it right, but:

https://dns-api.org/ptr/8.8.8.8.in-addr.arpa

seems to work just fine.
Title: Re: user of dns-api.org PTR lookup over http service broken
Post by: Weaver on July 21, 2018, 02:01:53 PM
ah - that is the standard format for making PTR requests - it just doesn't do it for you.

Well done, what a fool I was.
Title: Re: dns-api.org PTR lookup over http service broken
Post by: johnson on July 21, 2018, 02:18:44 PM
Didn't make any sense to me either, if you are already specifying a reverse lookup with /PTR/ why not add the in-addr.arpa automatically?
Title: Re: user of dns-api.org PTR lookup over http service broken
Post by: Weaver on July 21, 2018, 07:08:53 PM
indeed, I had to write a load of extra code because of that - to reverse the address and carve it up appropriately.
Title: Re: user of dns-api.org PTR lookup over http service broken
Post by: Weaver on July 21, 2018, 08:54:19 PM
Thank you to johnson anyway - at least someone is awake, what an utter fool I am. I have written a ptr lookup tool for the ipad based on this service, as I don't have access to the low level routines required to do it properly. (If I were to learn Python and use Pythonista then that might be a different matter tho.)

I have put in a caching / memoization module so it does not go to the network every single time. It is very cheap though. The next stage would be to add lifetimes to the cache entries and do things properly, as they should be done.