forked from TrueCloudLab/lego
lib: add recursive CNAME lookup support (#1677)
This commit is contained in:
parent
4c823ed3c0
commit
fd8a9f86ec
1 changed files with 11 additions and 4 deletions
|
@ -179,10 +179,17 @@ func GetRecord(domain, keyAuth string) (fqdn, value string) {
|
||||||
fqdn = fmt.Sprintf("_acme-challenge.%s.", domain)
|
fqdn = fmt.Sprintf("_acme-challenge.%s.", domain)
|
||||||
|
|
||||||
if ok, _ := strconv.ParseBool(os.Getenv("LEGO_EXPERIMENTAL_CNAME_SUPPORT")); ok {
|
if ok, _ := strconv.ParseBool(os.Getenv("LEGO_EXPERIMENTAL_CNAME_SUPPORT")); ok {
|
||||||
r, err := dnsQuery(fqdn, dns.TypeCNAME, recursiveNameservers, true)
|
// recursion counter so it doesn't spin out of control
|
||||||
// Check if the domain has CNAME then return that
|
for limit := 0; limit < 50; limit++ {
|
||||||
if err == nil && r.Rcode == dns.RcodeSuccess {
|
// Keep following CNAMEs
|
||||||
fqdn = updateDomainWithCName(r, fqdn)
|
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)
|
||||||
|
} else {
|
||||||
|
// No more CNAME records to follow, exit
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue