mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-09-09 06:35:29 +08:00
NAMESERVER() validity check fixed (#866)
This commit is contained in:
parent
c44d9a43f5
commit
408e7eb0ce
1 changed files with 9 additions and 7 deletions
|
@ -33,7 +33,7 @@ func checkTarget(target string) error {
|
||||||
if target == "@" {
|
if target == "@" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if len(target) < 1 {
|
if target == "" {
|
||||||
return fmt.Errorf("empty target")
|
return fmt.Errorf("empty target")
|
||||||
}
|
}
|
||||||
if strings.ContainsAny(target, `'" +,|!£$%&/()=?^*ç°§;:<>[]()@`) {
|
if strings.ContainsAny(target, `'" +,|!£$%&/()=?^*ç°§;:<>[]()@`) {
|
||||||
|
@ -92,7 +92,7 @@ func checkLabel(label string, rType string, target, domain string, meta map[stri
|
||||||
if label == "@" {
|
if label == "@" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if len(label) < 1 {
|
if label == "" {
|
||||||
return fmt.Errorf("empty %s label in %s", rType, domain)
|
return fmt.Errorf("empty %s label in %s", rType, domain)
|
||||||
}
|
}
|
||||||
if label[len(label)-1] == '.' {
|
if label[len(label)-1] == '.' {
|
||||||
|
@ -272,11 +272,13 @@ func ValidateAndNormalizeConfig(config *models.DNSConfig) (errs []error) {
|
||||||
// Normalize Nameservers.
|
// Normalize Nameservers.
|
||||||
for _, ns := range domain.Nameservers {
|
for _, ns := range domain.Nameservers {
|
||||||
// NB(tlim): Like any target, NAMESERVER() is input by the user
|
// NB(tlim): Like any target, NAMESERVER() is input by the user
|
||||||
// as a shortname or a FQDN+dot. It is stored as FQDN+dot.
|
// as a shortname or a FQDN+dot.
|
||||||
// Normalize it like we do any target to assure it is FQDN+dot
|
if err := checkTarget(ns.Name); err != nil {
|
||||||
ns.Name = dnsutil.AddOrigin(ns.Name, domain.Name+".")
|
errs = append(errs, err)
|
||||||
ns.Name = strings.TrimSuffix(ns.Name, ".")
|
}
|
||||||
checkTarget(ns.Name)
|
// Unlike any other FQDN in this system, it is stored as a FQDN without the trailing dot.
|
||||||
|
n := dnsutil.AddOrigin(ns.Name, domain.Name+".")
|
||||||
|
ns.Name = strings.TrimSuffix(n, ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize Records.
|
// Normalize Records.
|
||||||
|
|
Loading…
Add table
Reference in a new issue