Dont nest so deep. Used a goto for now
This commit is contained in:
parent
74cffb0578
commit
20b8675868
|
@ -19,7 +19,7 @@ var (
|
||||||
conf *dns.ClientConfig
|
conf *dns.ClientConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
func localQuery(qname string, qtype uint16) (r *dns.Msg, err error) {
|
func localQuery(qname string, qtype uint16) (*dns.Msg, error) {
|
||||||
localm.SetQuestion(qname, qtype)
|
localm.SetQuestion(qname, qtype)
|
||||||
for i := range conf.Servers {
|
for i := range conf.Servers {
|
||||||
server := conf.Servers[i]
|
server := conf.Servers[i]
|
||||||
|
@ -118,30 +118,31 @@ func main() {
|
||||||
if soa == nil {
|
if soa == nil {
|
||||||
success = false
|
success = false
|
||||||
fmt.Printf("%s (%s) ", ip, err)
|
fmt.Printf("%s (%s) ", ip, err)
|
||||||
} else {
|
goto Next
|
||||||
if soa.Rcode != dns.RcodeSuccess {
|
}
|
||||||
success = false
|
if soa.Rcode != dns.RcodeSuccess {
|
||||||
fmt.Printf("%s (%s) ", ips, dns.Rcode_str[soa.Rcode])
|
success = false
|
||||||
|
fmt.Printf("%s (%s) ", ips, dns.Rcode_str[soa.Rcode])
|
||||||
|
goto Next
|
||||||
|
}
|
||||||
|
if len(soa.Answer) == 0 { // May happen if the server is a recursor, not authoritative, since we query with RD=0
|
||||||
|
success = false
|
||||||
|
fmt.Printf("%s (0 answer) ", ip)
|
||||||
|
goto Next
|
||||||
|
}
|
||||||
|
rsoa := soa.Answer[0]
|
||||||
|
switch rsoa.(type) {
|
||||||
|
case *dns.RR_SOA:
|
||||||
|
if soa.MsgHdr.Authoritative {
|
||||||
|
// TODO: test if all name servers have the same serial ?
|
||||||
|
fmt.Printf("%s (%d) ", ips, rsoa.(*dns.RR_SOA).Serial)
|
||||||
} else {
|
} else {
|
||||||
if len(soa.Answer) == 0 { // May happen if the server is a recursor, not authoritative, since we query with RD=0
|
success = false
|
||||||
success = false
|
fmt.Printf("%s (not authoritative) ", ips)
|
||||||
fmt.Printf("%s (0 answer) ", ip)
|
|
||||||
} else {
|
|
||||||
rsoa := soa.Answer[0]
|
|
||||||
switch rsoa.(type) {
|
|
||||||
case *dns.RR_SOA:
|
|
||||||
if soa.MsgHdr.Authoritative {
|
|
||||||
// TODO: test if all name servers have the same serial ?
|
|
||||||
fmt.Printf("%s (%d) ", ips, rsoa.(*dns.RR_SOA).Serial)
|
|
||||||
} else {
|
|
||||||
success = false
|
|
||||||
fmt.Printf("%s (not authoritative) ", ips)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Next:
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue