An (Unofficial) Golang client for Farsight Security's DNSDB (https://api.dnsdb.info/)
import "github.com/bored-engineer/go-dnsdb"To list all RRSet records matching www.farsightsecurity.com:
records, _, err := client.RRSet.LookupName("www.farsightsecurity.com", nil)
if err != nil {
panic(err)
}
for _, record := range records {
fmt.Println("%s: %v", *record.RRName, record.RData)
}For furthur usage see the GoDocs.
The dnsdb library does not directly handle authentication. Instead, when creating a new client, you can pass a http.Client that handles authentication for you. It does provide a APIKeyTransport structure when using API Key authentication. It is used like this:
tp := dnsdb.APIKeyTransport{
APIKey: "<<your API key here>>",
}
client := dnsdb.NewClient(tp.Client())Assemblying those two fragments of code into a complete GoLang program:
package main
import "github.com/bored-engineer/go-dnsdb"
import "fmt"
func main() {
fmt.Println("starting dnsdb api test...")
tp := dnsdb.APIKeyTransport{
APIKey: "<<your API key here>>",
}
client := dnsdb.NewClient(tp.Client())
records, _, err := client.RRSet.LookupName("www.farsightsecurity.com", nil)
if err != nil {
panic(err)
}
for _, record := range records {
fmt.Println("%s: %v", *record.RRName, record.RData)
}
}