Iterative DNS resolver for Go.
The Resolve
method on dnsr.Resolver
queries DNS for given name and type (A
, NS
, CNAME
, etc.). The resolver caches responses for queries, and liberally (aggressively?) returns DNS records for a given name, not waiting for slow or broken name servers.
This code leans heavily on Miek Gieben’s excellent DNS library, and is currently in production use at Domainr.
go get github.com/nxgtw/domainr-dnsr
package main
import (
"fmt"
"github.com/domainr/dnsr"
"github.com/nxgtw/domainr-dnsr"
)
func main() {
r := dnsr.New(10000)
for _, rr := range r.Resolve("google.com", "TXT") {
fmt.Println(rr.String())
}
}
Or construct with dnsr.NewExpiring()
to expire cache entries based on TTL.
Run go generate
in Go 1.4+ to refresh the root zone hint file. Pull requests welcome.
© 2014–2015 nb.io, LLC