feat: manage TLSA records
This commit is contained in:
1 parent
9c2fb9d15b
commit
a67183b646
14 files changed
+141
-15
No files matched your search
+12
-1
@@ -68,6 +68,13 @@ type caaData struct {
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
type tlsaData struct {
|
||||
Usage uint8 `json:"usage"`
|
||||
Selector uint8 `json:"selector"`
|
||||
MatchingType uint8 `json:"matching_type"`
|
||||
Certificate string `json:"certificate"`
|
||||
}
|
||||
|
||||
type soaData struct {
|
||||
NS string `json:"ns"`
|
||||
MBox string `json:"MBox"`
|
||||
@@ -182,7 +189,7 @@ func fieldDescription(kind reflect.Kind) string {
|
||||
|
||||
func encodeRecord(data any) (string, error) {
|
||||
switch data.(type) {
|
||||
case aData, aaaaData, cnameData, nsData, mxData, txtData, srvData, caaData, soaData:
|
||||
case aData, aaaaData, cnameData, nsData, mxData, txtData, srvData, caaData, tlsaData, soaData:
|
||||
encoded, err := json.Marshal(data)
|
||||
return string(encoded), err
|
||||
default:
|
||||
@@ -307,6 +314,10 @@ func buildRecordRR(row recordRow, data any, now time.Time) (dns.RR, error) {
|
||||
if v.Tag != "" && v.Value != "" {
|
||||
return &dns.CAA{Hdr: header, Flag: v.Flag, Tag: v.Tag, Value: v.Value}, nil
|
||||
}
|
||||
case tlsaData:
|
||||
if v.Certificate != "" {
|
||||
return &dns.TLSA{Hdr: header, Usage: v.Usage, Selector: v.Selector, MatchingType: v.MatchingType, Certificate: v.Certificate}, nil
|
||||
}
|
||||
case soaData:
|
||||
if v.Serial == 0 {
|
||||
v.Serial = uint32(now.Unix())
|
||||
|
||||
Reference in new issue
Block a user