Skip to content

Commit

Permalink
update: dns check for ns.dns.cluster.local ip looking up
Browse files Browse the repository at this point in the history
  • Loading branch information
Esonhugh committed Jul 20, 2024
1 parent 43fd284 commit 378806e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pkg/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func CheckKubeDNS(dns ...*SpiderResolver) bool {
if len(dns) > 0 { // use custom dns
rs = dns[0]
}
if CheckKubeDNS_DefaultAPIServer(rs) || CheckKubeDNS_DNSVersion(rs) {
if CheckKubeDNS_DefaultAPIServer(rs) || CheckKubeDNS_DNSVersion(rs) || CheckKubeDNS_NS_DNS_DOMAIN(rs) {
return true
}
}
Expand Down Expand Up @@ -81,3 +81,19 @@ func CheckKubeDNS_DNSVersion(dns *SpiderResolver) bool {
log.Tracef("dns-version not found in dns(%v)", dns.CurrentDNS())
return false
}

func CheckKubeDNS_NS_DNS_DOMAIN(dns *SpiderResolver) bool {
info, err := dns.ARecord("ns.dns." + Zone)
if err == nil {
log.Infof("ns.dns.%v found in dns(%v)! response: %v", Zone, dns.CurrentDNS(), info)
return true
}
log.Tracef("ns.dns.%v not found in dns(%v)", Zone, dns.CurrentDNS())
info, err = dns.ARecord("ns.dns") // try shorted if Zone is incorrect
if err == nil {
log.Warnf("ns.dns found in dns(%v)! response: %v, maybe %v is incorrect", dns.CurrentDNS(), info, Zone)
return true
}
log.Tracef("ns.dns not found in dns(%v)", dns.CurrentDNS())
return false
}

0 comments on commit 378806e

Please sign in to comment.