cname: stop trying to traverse cname if none have been found (#1733)

Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
This commit is contained in:
Jürgen Brunink 2022-10-10 20:43:33 +02:00 committed by GitHub
parent 79fcc56402
commit 5e37ee3822
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -194,15 +194,19 @@ func getChallengeFqdn(domain string) string {
// Keep following CNAMEs
r, err := dnsQuery(fqdn, dns.TypeCNAME, recursiveNameservers, true)
// Check if the domain has CNAME then use that
if err == nil && r.Rcode == dns.RcodeSuccess {
fqdn = updateDomainWithCName(r, fqdn)
continue
}
if err != nil || r.Rcode != dns.RcodeSuccess {
// No more CNAME records to follow, exit
break
}
// Check if the domain has CNAME then use that
cname := updateDomainWithCName(r, fqdn)
if cname == fqdn {
break
}
fqdn = cname
}
return fqdn
}