simple resolve for home stuffs
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
5a145eb34c
commit
e30da984f6
1 changed files with 9 additions and 15 deletions
24
main.go
24
main.go
|
@ -1,13 +1,15 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
dns "github.com/Focinfi/go-dns-resolver"
|
||||
)
|
||||
|
||||
func main() {
|
||||
domains := []string{"google.com", "twitter.com"}
|
||||
//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}
|
||||
|
||||
|
@ -15,17 +17,6 @@ func main() {
|
|||
dns.Config.SetTimeout(uint(2))
|
||||
dns.Config.RetryTimes = uint(4)
|
||||
|
||||
// Simple usage
|
||||
_ = func() {
|
||||
if results, err := dns.Exchange("google.com", "119.29.29.29:53", dns.TypeA); err == nil {
|
||||
for _, r := range results {
|
||||
log.Println(r.Record, r.Type, r.Ttl, r.Priority, r.Content)
|
||||
}
|
||||
} else {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Create and setup resolver with domains and types
|
||||
resolver := dns.NewResolver("10.0.30.1")
|
||||
resolver.Targets(domains...).Types(types...)
|
||||
|
@ -34,9 +25,12 @@ func main() {
|
|||
|
||||
//res.ResMap is a map[string]*ResultItem, key is the domain
|
||||
for target := range res.ResMap {
|
||||
log.Printf("%v: \n", target)
|
||||
//log.Printf("%v: \n", target)
|
||||
for _, r := range res.ResMap[target] {
|
||||
log.Println(r.Record, r.Type, r.Ttl, r.Priority, r.Content)
|
||||
if len(r.Content) != 0 {
|
||||
fmt.Println(r.Content)
|
||||
}
|
||||
//log.Println(r.Record, r.Type, r.Ttl, r.Priority, r.Content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue