1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Allow for Name's that start with _ (#830)

* Allow for Name's that start with _

* update tests

Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
Tom Misilo
2020-08-30 19:35:07 -05:00
committed by GitHub
parent de308c0952
commit cb9a82717b
2 changed files with 10 additions and 28 deletions

View File

@@ -85,20 +85,6 @@ func validateRecordTypes(rec *models.RecordConfig, domain string, pTypes []strin
return nil
}
// underscores in names are often used erroneously. They are valid for dns records, but invalid for urls.
// here we list common records expected to have underscores. Anything else containing an underscore will print a warning.
var labelUnderscores = []string{
"_acme-challenge",
"_amazonses",
"_dmarc",
"_domainconnect",
"_domainkey",
"_jabber",
"_mta-sts",
"_sip",
"_xmpp",
}
// these record types may contain underscores
var rTypeUnderscores = []string{"SRV", "TLSA", "TXT"}
@@ -127,17 +113,12 @@ func checkLabel(label string, rType string, target, domain string, meta map[stri
return nil
}
}
// Don't warn for CNAMEs if the target ends with acm-validations.aws
// See https://github.com/StackExchange/dnscontrol/issues/519
if strings.HasPrefix(label, "_") && rType == "CNAME" && strings.HasSuffix(target, ".acm-validations.aws.") {
// Don't warn for records that start with _
// See https://github.com/StackExchange/dnscontrol/issues/829
if strings.HasPrefix(label, "_") || strings.Contains(label, "._") {
return nil
}
// Don't warn for certain label substrings
for _, ex := range labelUnderscores {
if strings.Contains(label, ex) {
return nil
}
}
// Otherwise, warn.
if strings.ContainsRune(label, '_') {
return Warning{fmt.Errorf("label %s.%s contains an underscore", label, domain)}