Reputation: 269
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
?
Upvotes: 6
Views: 965
Reputation: 39364
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...
Upvotes: 5