mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-12-09 13:46:07 +08:00
# Issue Fixes https://github.com/StackExchange/dnscontrol/issues/3842 CC @das7pad # Resolution Convert domain.Name to IDN earlier in the pipeline. Hack the --domains processing to convert everything to IDN. * Domain names are now stored 3 ways: The original input from dnsconfig.js, canonical IDN format (`xn--...`), and Unicode format. All are downcased. Providers that haven't been updated will receive the IDN format instead of the original input format. This might break some providers but only for users with unicode in their D("domain.tld"). PLEASE TEST YOUR PROVIDER. * BIND filename formatting options have been added to access the new formats. # Breaking changes * BIND zonefiles may change. The default used the name input in the D() statement. It now defaults to the IDN name + "!tag" if there is a tag. * Providers that are not IDN-aware may break (hopefully only if they weren't processing IDN already) --------- Co-authored-by: Jakob Ackermann <das7pad@outlook.com>
52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
package models
|
|
|
|
import (
|
|
"fmt"
|
|
"slices"
|
|
"strconv"
|
|
)
|
|
|
|
// SetTargetCAA sets the CAA fields.
|
|
func (rc *RecordConfig) SetTargetCAA(flag uint8, tag string, target string) error {
|
|
rc.CaaTag = tag
|
|
rc.CaaFlag = flag
|
|
if err := rc.SetTarget(target); err != nil {
|
|
return err
|
|
}
|
|
if rc.Type == "" {
|
|
rc.Type = "CAA"
|
|
}
|
|
if rc.Type != "CAA" {
|
|
panic("assertion failed: SetTargetCAA called when .Type is not CAA")
|
|
}
|
|
|
|
// Per: https://www.iana.org/assignments/pkix-parameters/pkix-parameters.xhtml#caa-properties excluding reserved tags
|
|
allowedTags := []string{"issue", "issuewild", "iodef", "contactemail", "contactphone", "issuemail", "issuevmc"}
|
|
if !slices.Contains(allowedTags, tag) {
|
|
return fmt.Errorf("CAA tag (%v) is not one of the valid types", tag)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// SetTargetCAAStrings is like SetTargetCAA but accepts strings.
|
|
func (rc *RecordConfig) SetTargetCAAStrings(flag, tag, target string) error {
|
|
i64flag, err := strconv.ParseUint(flag, 10, 8)
|
|
if err != nil {
|
|
return fmt.Errorf("CAA flag does not fit in 8 bits: %w", err)
|
|
}
|
|
return rc.SetTargetCAA(uint8(i64flag), tag, target)
|
|
}
|
|
|
|
// SetTargetCAAString is like SetTargetCAA but accepts one big string.
|
|
// Ex: `0 issue "letsencrypt.org"`
|
|
func (rc *RecordConfig) SetTargetCAAString(s string) error {
|
|
part, err := ParseQuotedFields(s)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if len(part) != 3 {
|
|
return fmt.Errorf("CAA value does not contain 3 fields: (%#v)", s)
|
|
}
|
|
return rc.SetTargetCAAStrings(part[0], part[1], part[2])
|
|
}
|