mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Improve warnings related to _ and TTLs (#1989)
This commit is contained in:
@@ -126,13 +126,13 @@ func checkLabel(label string, rType string, target, domain string, meta map[stri
|
||||
}
|
||||
// Don't warn for records that start with _
|
||||
// See https://github.com/StackExchange/dnscontrol/issues/829
|
||||
if strings.HasPrefix(label, "_") || strings.Contains(label, "._") {
|
||||
if strings.HasPrefix(label, "_") || strings.Contains(label, "._") || strings.HasPrefix(label, "sql-") {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Otherwise, warn.
|
||||
if strings.ContainsRune(label, '_') {
|
||||
return Warning{fmt.Errorf("label %s.%s contains an underscore", label, domain)}
|
||||
return Warning{fmt.Errorf("label %s.%s contains \"_\" (can't be used in a URL)", label, domain)}
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -598,9 +598,15 @@ func checkLabelHasMultipleTTLs(records []*models.RecordConfig) (errs []error) {
|
||||
}
|
||||
|
||||
for label := range m {
|
||||
// if after the uniq() pass we still have more than one ttl, it means we have multiple TTLs for that label
|
||||
if len(uniq(m[label])) > 1 {
|
||||
errs = append(errs, Warning{fmt.Errorf("multiple TTLs detected for: %s. This should be avoided", label)})
|
||||
// The RFCs say that all records at a particular label should have
|
||||
// the same TTL. Most providers don't care, and if they do the
|
||||
// code usually picks the lowest TTL for all of them.
|
||||
//
|
||||
// If after the uniq() pass we still have more than one ttl, it
|
||||
// means we have multiple TTLs for that label.
|
||||
u := uniq(m[label])
|
||||
if len(u) > 1 {
|
||||
errs = append(errs, Warning{fmt.Errorf("label with multipe TTLs: %s (%v)", label, u)})
|
||||
}
|
||||
}
|
||||
return errs
|
||||
|
Reference in New Issue
Block a user