func unboundcheck(u *unbound.Unbound, zone string, typ string) *result { var errstr string zone = strings.TrimSpace(zone) r := new(result) r.name = zone lg.Printf("checking %s %s\n", zone, typ) if zone == "" { return r } dnstype := dns.TypeNS r.typ = "NS" typ = strings.ToUpper(typ) if v, ok := TYPES[typ]; ok { dnstype = v r.typ = typ } res, err := u.Resolve(zone, dnstype, dns.ClassINET) if err != nil { r.err = err.Error() return r } if res.Rcode == 0 { errstr = "" } else { if res.Rcode == 2 { errstr = "(servfail)" } else { if res.Rcode == 3 { errstr = "(nxdomain)" } else { errstr = fmt.Sprintf("(rcode: %d)", res.Rcode) } } } r.err = errstr if res.HaveData || res.NxDomain { if res.Secure { r.status = "secure" } else if res.Bogus { r.status = "bogus" r.why = res.WhyBogus } else { r.status = "insecure" } } else { // r.status = "n/a" if errstr != "" { errstr = " " + errstr } r.err = fmt.Sprintf("nodata%s", errstr) } return r }
func goroutineTwo(u *unbound.Unbound, quit chan bool) { r, err := u.Resolve("www.google.nl.", dns.TypeA, dns.ClassINET) if err != nil { fmt.Printf("resolve error %s\n", err.Error()) quit <- true return } if r.HaveData { fmt.Printf("Routine2: The address of %s is %v\n", r.Qname, r.Data[0]) } quit <- true return }