golang-examples/example-lookupAAAA/main.go

29 lines
558 B
Go

package main
import "log"
import "github.com/miekg/dns"
import "git.wit.org/jcarr/dnssecsocket"
import "github.com/davecgh/go-spew/spew"
// import "github.com/Showmax/go-fqdn"
func lookupAAAA(hostname string) string {
// lookup the IP address from DNS
dnsRR := dnssecsocket.Dnstrace(hostname, "AAAA")
spew.Dump(dnsRR)
if (dnsRR == nil) {
return "BROKEN"
}
ipaddr := dns.Field(dnsRR, 1)
log.Println("ipaddr", ipaddr)
return ipaddr
}
func main() {
hostname := "check.lab.wit.org"
// 2604:bbc0:2:248:5054:f0ff:fe00:156
lookupAAAA(hostname)
}