pki/vendor/github.com/go-acme/lego/v4/challenge/dns01/cname.go

21 lines
320 B
Go
Raw Normal View History

2020-11-25 20:36:07 +01:00
package dns01
2023-10-01 12:07:22 +02:00
import (
"strings"
"github.com/miekg/dns"
)
2020-11-25 20:36:07 +01:00
// Update FQDN with CNAME if any.
func updateDomainWithCName(r *dns.Msg, fqdn string) string {
for _, rr := range r.Answer {
if cn, ok := rr.(*dns.CNAME); ok {
2023-10-01 12:07:22 +02:00
if strings.EqualFold(cn.Hdr.Name, fqdn) {
2020-11-25 20:36:07 +01:00
return cn.Target
}
}
}
return fqdn
}