FEATURE: Detect simple CNAME loops (#2112)

This commit is contained in:
Tom Limoncelli 2023-03-01 10:15:41 -05:00 committed by GitHub
parent b54c5eab10
commit dde7e5daf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -187,6 +187,11 @@ func checkTargets(rec *models.RecordConfig, domain string) (errs []error) {
if label == "@" {
check(fmt.Errorf("cannot create CNAME record for bare domain"))
}
labelFQDN := dnsutil.AddOrigin(label, domain)
targetFQDN := dnsutil.AddOrigin(target, domain)
if labelFQDN == targetFQDN {
check(fmt.Errorf("CNAME loop (target points at itself)"))
}
case "MX":
check(checkTarget(target))
case "NAPTR":