예제 #1
0
파일: check.go 프로젝트: SIDN/unboundcheck
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
}
예제 #2
0
파일: example.go 프로젝트: vofam/unbound
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
}
예제 #3
0
파일: check.go 프로젝트: SIDN/unboundcheck
// Setup the resolver and add the root's trust anchor
// This one is used for RESTful lookups - they contain detailed errors
func setupUnbound(u *unbound.Unbound) {
	//	u.ResolvConf("/etc/resolv.conf")
	u.AddTa(`;; ANSWER SECTION:
.                       168307 IN DNSKEY 257 3 8 (
                                AwEAAagAIKlVZrpC6Ia7gEzahOR+9W29euxhJhVVLOyQ
                                bSEW0O8gcCjFFVQUTf6v58fLjwBd0YI0EzrAcQqBGCzh
                                /RStIoO8g0NfnfL2MTJRkxoXbfDaUeVPQuYEhg37NZWA
                                JQ9VnMVDxP/VHL496M/QZxkjf5/Efucp2gaDX6RS6CXp
                                oY68LsvPVjR0ZSwzz1apAzvN9dlzEheX7ICJBBtuA6G3
                                LQpzW5hOA2hzCTMjJPJ8LbqF6dsV6DoBQzgul0sGIcGO
                                Yl7OyQdXfZ57relSQageu+ipAdTTJ25AsRTAoub8ONGc
                                LmqrAmRLKBP1dfwhYB4N7knNnulqQxA+Uk1ihz0=
                                ) ; key id = 19036`)
}