Skip to content

Commit 378806e

Browse files
committed
update: dns check for ns.dns.cluster.local ip looking up
1 parent 43fd284 commit 378806e

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

pkg/utils.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func CheckKubeDNS(dns ...*SpiderResolver) bool {
4343
if len(dns) > 0 { // use custom dns
4444
rs = dns[0]
4545
}
46-
if CheckKubeDNS_DefaultAPIServer(rs) || CheckKubeDNS_DNSVersion(rs) {
46+
if CheckKubeDNS_DefaultAPIServer(rs) || CheckKubeDNS_DNSVersion(rs) || CheckKubeDNS_NS_DNS_DOMAIN(rs) {
4747
return true
4848
}
4949
}
@@ -81,3 +81,19 @@ func CheckKubeDNS_DNSVersion(dns *SpiderResolver) bool {
8181
log.Tracef("dns-version not found in dns(%v)", dns.CurrentDNS())
8282
return false
8383
}
84+
85+
func CheckKubeDNS_NS_DNS_DOMAIN(dns *SpiderResolver) bool {
86+
info, err := dns.ARecord("ns.dns." + Zone)
87+
if err == nil {
88+
log.Infof("ns.dns.%v found in dns(%v)! response: %v", Zone, dns.CurrentDNS(), info)
89+
return true
90+
}
91+
log.Tracef("ns.dns.%v not found in dns(%v)", Zone, dns.CurrentDNS())
92+
info, err = dns.ARecord("ns.dns") // try shorted if Zone is incorrect
93+
if err == nil {
94+
log.Warnf("ns.dns found in dns(%v)! response: %v, maybe %v is incorrect", dns.CurrentDNS(), info, Zone)
95+
return true
96+
}
97+
log.Tracef("ns.dns not found in dns(%v)", dns.CurrentDNS())
98+
return false
99+
}

0 commit comments

Comments
 (0)