main: just get the A records from our resolver

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2021-07-22 22:09:14 -04:00
parent 0f61a07c76
commit 5a145eb34c
Signed by: vbatts
GPG Key ID: 10937E57733F1362
1 changed files with 10 additions and 7 deletions

17
main.go
View File

@ -8,23 +8,26 @@ import (
func main() {
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
dns.Config.SetTimeout(uint(2))
dns.Config.RetryTimes = uint(4)
// Simple usage
if results, err := dns.Exchange("google.com", "119.29.29.29", dns.TypeA); err == nil {
for _, r := range results {
log.Println(r.Record, r.Type, r.Ttl, r.Priority, r.Content)
_ = 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)
}
} else {
log.Fatal(err)
}
// 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...)
// Lookup
res := resolver.Lookup()