CHORE: Clarify TXT string limits (#2691)

This commit is contained in:
Tom Limoncelli 2023-12-06 16:23:18 -05:00 committed by GitHub
parent 0c70048253
commit 377193926c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 21 deletions

View file

@ -73,3 +73,15 @@ func TxtLongerThan255(rc *models.RecordConfig) error {
}
return nil
}
// TxtLongerThan returns a function that audits TXT records for length
// greater than maxLength.
func TxtLongerThan(maxLength int) func(rc *models.RecordConfig) error {
return func(rc *models.RecordConfig) error {
m := maxLength
if len(rc.GetTargetTXTJoined()) > m {
return fmt.Errorf("TXT records longer than %d octets (chars)", m)
}
return nil
}
}

View file

@ -21,8 +21,6 @@ func AuditRecords(records []*models.RecordConfig) []error {
a.Add("TXT", rejectif.TxtIsEmpty) // Last verified 2023-12-03
//a.Add("TXT", rejectif.TxtLongerThan255) // Last verified 2022-06-10
return a.Audit(records)
}

View file

@ -21,10 +21,6 @@ func AuditRecords(records []*models.RecordConfig) []error {
a.Add("TXT", rejectif.TxtHasBackslash) // Last verified 2023-11-11
a.Add("TXT", rejectif.TxtHasDoubleQuotes) // Last verified 2021-03-01
// Double-quotes not permitted in TXT strings. I have a hunch that
// this is due to a broken parser on the DO side.
a.Add("TXT", rejectif.TxtIsEmpty) // Last verified 2023-11-11
return a.Audit(records)

View file

@ -1,8 +1,6 @@
package loopia
import (
"fmt"
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/rejectif"
)
@ -15,20 +13,10 @@ func AuditRecords(records []*models.RecordConfig) []error {
a.Add("TXT", rejectif.TxtIsEmpty) // Last verified 2023-03-10: Loopia returns 404
//Loopias TXT length limit appears to be 450 octets
a.Add("TXT", TxtHasSegmentLen450orLonger)
// Loopias TXT length limit appears to be 450 octets
a.Add("TXT", rejectif.TxtLongerThan(450)) // Last verified 2023-03-10
a.Add("MX", rejectif.MxNull) // Last verified 2023-03-23
return a.Audit(records)
}
// TxtHasSegmentLen450orLonger audits TXT records for strings that are >450 octets.
func TxtHasSegmentLen450orLonger(rc *models.RecordConfig) error {
for _, txt := range rc.GetTargetTXTSegmented() {
if len(txt) > 450 {
return fmt.Errorf("%q txtstring length > 450", rc.GetLabel())
}
}
return nil
}

View file

@ -19,7 +19,7 @@ func AuditRecords(records []*models.RecordConfig) []error {
a.Add("TXT", rejectif.TxtHasDoubleQuotes) // Last verified 2023-02-02
a.Add("TXT", rejectif.TxtLongerThan255) // Last verified 2023-02-02
a.Add("TXT", rejectif.TxtLongerThan(255)) // Last verified 2023-02-02
a.Add("TXT", rejectif.TxtHasSingleQuotes) // Last verified 2023-02-02