Remove length checking from TxtNoMultipleStrings (#1308)

All functions in should test for only one condition. There already is a
function that tests for long TXT records: TxtNoLongStrings.
Add calls to TxtNoLongStrings in all providers that use
TxtNoMultipleStrings, to keep functionality, except for NS1 and ClouDNS,
which allow for any TXT record length, but not for multiple strings per
TXT.
This commit is contained in:
norman-zon 2021-11-23 20:35:01 +01:00 committed by GitHub
parent 3405757271
commit 58a5a4bcf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 17 deletions

View file

@ -97,8 +97,6 @@ func TxtNoMultipleStrings(records []*models.RecordConfig) error {
if rc.HasFormatIdenticalToTXT() { // TXT and similar:
if len(rc.TxtStrings) > 1 {
return fmt.Errorf("multiple strings in one txt")
} else if len(rc.TxtStrings) == 1 && len(rc.TxtStrings[0]) > 255 {
return fmt.Errorf("strings >255 octets")
}
}

View file

@ -1,7 +1,6 @@
package cloudns
import (
"fmt"
"github.com/StackExchange/dnscontrol/v3/models"
"github.com/StackExchange/dnscontrol/v3/pkg/recordaudit"
)
@ -30,22 +29,9 @@ func AuditRecords(records []*models.RecordConfig) error {
}
// Still needed as of 2021-03-11
if err := txtNoMultipleStrings(records); err != nil {
if err := recordaudit.TxtNoMultipleStrings(records); err != nil {
return err
}
return nil
}
// ClouDNS NOT allow multiple TXT records with same name
// But allow values longer the 255
func txtNoMultipleStrings(records []*models.RecordConfig) error {
for _, rc := range records {
if rc.HasFormatIdenticalToTXT() { // TXT and similar:
if len(rc.TxtStrings) > 1 {
return fmt.Errorf("multiple strings in one txt")
}
}
}
return nil
}

View file

@ -14,6 +14,10 @@ func AuditRecords(records []*models.RecordConfig) error {
}
// Still needed as of 2021-03-01
if err := recordaudit.TxtNoLongStrings(records); err != nil {
return err
}
if err := recordaudit.TxtNotEmpty(records); err != nil {
return err
}

View file

@ -20,5 +20,9 @@ func AuditRecords(records []*models.RecordConfig) error {
return err
}
if err := recordaudit.TxtNoLongStrings(records); err != nil {
return err
}
return nil
}