DNS: TTL or GetServers?

:wave: Hi I have been looking for a way to get ttl numbers for dns TXT entries. As it seems the golang standard library doesn’t support ttl for entries I have been looking into miekg/dns. It works well, but for it to work out-of-the-box I need to get the systems dns servers. Since the system settings are per network interface I was assuming net.Interfaces() to have a Interface.DNS property or have a net.DNSServers() function available.

Do you know a different library that could help with this?
Do you think this should be a golang standard library issue?
Do you think it should be a feature of the golang std lib to support TTL’s for dns entries?
Should this be a feature of third party libraries like miekd/dns?

Note: From using it in Node.js it seems it should be possible to implement it in a cross-plattform manner. Possibly because Node is using c-ares in the background?

$ node -p "(new dns.Resolver).getServers()"

Hi @martinheidegger, welcome to the forum.

Regarding getting the system’s list of DNS servers, this SO answer suggests parsing /etc/resolv.conf like Ruby does.

I cannot comment on whether getting TTL data should be a feature of the stdlib or of third-party packages. This is the decision of the Go team or anyone who wrote, or plans to write, a DNS package. But I found package retryabledns that appears to include TTL data as part of a TXT response, which might suit your needs.

Hi @christophberger

retryabledns is a dead-end as it uses miekg/dns under the hood :sweat:

The SO answer points to the right direction how to implement it, even if it has a dead link. Here is the bits of implementation that I found:

It will actually handle the windows case separately using win32/resolv - so pretty complex. Trying to support seems to be more than a quick “5 min and done” project :sweat_smile: and I am wondering where may be persons that are interested (maybe more than I am) to implement it.

Indeed, Windows can add complexity to cross-platform solutions…