feat: manage TLSA records
Test / test (push) Successful in 28m4s
Build and publish image / image (push) Successful in 28m43s

This commit is contained in:
bryanpedini committed 2026-11-22 11:31:59 +01:00
1 parent 9c2fb9d15b
commit a67183b646
14 files changed
+141 -15

No files matched your search

+16
View File
@@ -5,6 +5,7 @@ package main
import (
"cmp"
"encoding/hex"
"errors"
"net/netip"
"reflect"
@@ -31,6 +32,7 @@ var recordRules = map[string]recordTypeRule{
"TXT": {dns.TypeTXT, reflect.TypeFor[txtData]()},
"SRV": {dns.TypeSRV, reflect.TypeFor[srvData]()},
"CAA": {dns.TypeCAA, reflect.TypeFor[caaData]()},
"TLSA": {dns.TypeTLSA, reflect.TypeFor[tlsaData]()},
"SOA": {dns.TypeSOA, reflect.TypeFor[soaData]()},
}
@@ -120,6 +122,20 @@ func normalizeRecordData(zone string, data any) (any, map[string]string) {
fields["tag"] = "must contain 1 to 15 lowercase ASCII letters or digits"
}
text("value", v.Value, 1024)
case tlsaData:
v.Certificate = strings.ToLower(v.Certificate)
certificate, err := hex.DecodeString(v.Certificate)
switch {
case err != nil || len(certificate) == 0:
fields["certificate"] = "must be a non-empty even-length hexadecimal string"
case len(certificate) > 65535-3:
fields["certificate"] = "must be at most 65532 bytes"
case v.MatchingType == 1 && len(certificate) != 32:
fields["certificate"] = "must be a 32-byte SHA-256 digest for matching type 1"
case v.MatchingType == 2 && len(certificate) != 64:
fields["certificate"] = "must be a 64-byte SHA-512 digest for matching type 2"
}
data = v
case soaData:
v.NS = host("ns", v.NS, false)
mailbox, err := normalizeMailbox(v.MBox)