I am attempting to query NAPTR
records in Go. It appears the DNS
basics provided in the 'net' library won't give me access. I am therefore looking at using (see docs), but can't find any basic examples. Are there any recommendations on alternatives or some insight on how to query for NAPTR
?
¶ NAPTR records, short for Naming Authority Pointer, is a type of record that allows you to set dynamic rules for how your website processes requests. This type of record is especially useful to websites that provide internet telephony services.
Answer: No, they are not the same. PTR records are used for Reverse DNS Resolution. And NAPTR records are mostly used for SIP communication.
The combination of NAPTR records with Service Records (SRV) allows the chaining of multiple records to form complex rewrite rules which produce new domain labels or uniform resource identifiers (URIs). The DNS type code for the NAPTR record is 35.
AFAIK, you would have to roll your own for the net library. Using miekg/dns, I would think something like this:
m := new(dns.Msg)
m.SetQuestion("statdns.net.", dns.TypeNAPTR)
ret, err := dns.Exchange(m, "8.8.8.8:53")
From the ret
, you should have an Answer
member of []RR
. I'm presupposing you can access like:
if t, ok := ret.Answer[0].(*dns.NAPTR); ok {
// do something with t.Order, t.Preference, etc.
}
The available members are defined in the NAPTR type.
Caveat emptor: I'm away from my workstation for a bit and can't try this out...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With