main: just get the A records from our resolver
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
0f61a07c76
commit
5a145eb34c
1 changed files with 10 additions and 7 deletions
9
main.go
9
main.go
|
@ -8,23 +8,26 @@ import (
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
domains := []string{"google.com", "twitter.com"}
|
domains := []string{"google.com", "twitter.com"}
|
||||||
types := []dns.QueryType{dns.TypeA, dns.TypeNS, dns.TypeMX, dns.TypeTXT}
|
//types := []dns.QueryType{dns.TypeA, dns.TypeNS, dns.TypeMX, dns.TypeTXT}
|
||||||
|
types := []dns.QueryType{dns.TypeA}
|
||||||
|
|
||||||
// Set timeout and retry times
|
// Set timeout and retry times
|
||||||
dns.Config.SetTimeout(uint(2))
|
dns.Config.SetTimeout(uint(2))
|
||||||
dns.Config.RetryTimes = uint(4)
|
dns.Config.RetryTimes = uint(4)
|
||||||
|
|
||||||
// Simple usage
|
// Simple usage
|
||||||
if results, err := dns.Exchange("google.com", "119.29.29.29", dns.TypeA); err == nil {
|
_ = func() {
|
||||||
|
if results, err := dns.Exchange("google.com", "119.29.29.29:53", dns.TypeA); err == nil {
|
||||||
for _, r := range results {
|
for _, r := range results {
|
||||||
log.Println(r.Record, r.Type, r.Ttl, r.Priority, r.Content)
|
log.Println(r.Record, r.Type, r.Ttl, r.Priority, r.Content)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create and setup resolver with domains and types
|
// Create and setup resolver with domains and types
|
||||||
resolver := dns.NewResolver("119.29.29.29")
|
resolver := dns.NewResolver("10.0.30.1")
|
||||||
resolver.Targets(domains...).Types(types...)
|
resolver.Targets(domains...).Types(types...)
|
||||||
// Lookup
|
// Lookup
|
||||||
res := resolver.Lookup()
|
res := resolver.Lookup()
|
||||||
|
|
Loading…
Add table
Reference in a new issue