37 lines
875 B
Go
37 lines
875 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
dns "github.com/Focinfi/go-dns-resolver"
|
|
)
|
|
|
|
func main() {
|
|
//domains := []string{"google.com", "twitter.com"}
|
|
domains := []string{os.Args[1]}
|
|
//types := []dns.QueryType{dns.TypeA, dns.TypeNS, dns.TypeMX, dns.TypeTXT}
|
|
types := []dns.QueryType{dns.TypeA}
|
|
|
|
// Set timeout and retry times
|
|
dns.Config.SetTimeout(uint(2))
|
|
dns.Config.RetryTimes = uint(4)
|
|
|
|
// Create and setup resolver with domains and types
|
|
resolver := dns.NewResolver("10.0.30.1")
|
|
resolver.Targets(domains...).Types(types...)
|
|
// Lookup
|
|
res := resolver.Lookup()
|
|
|
|
//res.ResMap is a map[string]*ResultItem, key is the domain
|
|
for target := range res.ResMap {
|
|
//log.Printf("%v: \n", target)
|
|
for _, r := range res.ResMap[target] {
|
|
if len(r.Content) != 0 {
|
|
fmt.Println(r.Content)
|
|
}
|
|
//log.Println(r.Record, r.Type, r.Ttl, r.Priority, r.Content)
|
|
}
|
|
}
|
|
}
|