add missing handling of dhcid

This commit is contained in:
Florian Ritterhoff 2023-09-10 08:05:26 +02:00
parent 3e1e7aeb8e
commit b6e183d4b5
7 changed files with 34 additions and 21 deletions

View file

@ -536,6 +536,10 @@ func cname(name, target string) *models.RecordConfig {
return makeRec(name, target, "CNAME")
}
func dhcid(name, target string) *models.RecordConfig {
return makeRec(name, target, "DHCID")
}
func ds(name string, keyTag uint16, algorithm, digestType uint8, digest string) *models.RecordConfig {
r := makeRec(name, "", "DS")
r.SetTargetDS(keyTag, algorithm, digestType, digest)
@ -1554,6 +1558,11 @@ func makeTests(t *testing.T) []*TestGroup {
// ns("another-child", "ns101.cloudns.net."),
//),
),
testgroup("PTR",
requires(providers.CanUsePTR),
tc("Create DHCPID record", dhcid("test", "AAIBY2/AuCccgoJbsaxcQc9TUapptP69lOjxfNuVAA2kjEA=")),
tc("Modify DHCPID record", dhcid("test", "Test/AuCccgoJbsaxcQc9TUapptP69lOjxfNuVAA2kjEA=")),
),
//// Vendor-specific record types

View file

@ -135,7 +135,7 @@ func (dc *DomainConfig) Punycode() error {
rec.SetTarget(t)
case "CF_REDIRECT", "CF_TEMP_REDIRECT", "CF_WORKER_ROUTE":
rec.SetTarget(rec.GetTargetField())
case "A", "AAAA", "CAA", "DS", "LOC", "NAPTR", "SOA", "SSHFP", "TXT", "TLSA", "AZURE_ALIAS":
case "A", "AAAA", "CAA", "DHCPID", "DS", "LOC", "NAPTR", "SOA", "SSHFP", "TXT", "TLSA", "AZURE_ALIAS":
// Nothing to do.
default:
return fmt.Errorf("Punycode rtype %v unimplemented", rec.Type)

View file

@ -595,7 +595,7 @@ func Downcase(recs []*RecordConfig) {
// Target is case insensitive. Downcase it.
r.target = strings.ToLower(r.target)
// BUGFIX(tlim): isn't ALIAS in the wrong case statement?
case "A", "ALIAS", "CAA", "CF_REDIRECT", "CF_TEMP_REDIRECT", "CF_WORKER_ROUTE", "IMPORT_TRANSFORM", "LOC", "SSHFP", "TXT":
case "A", "ALIAS", "CAA", "CF_REDIRECT", "CF_TEMP_REDIRECT", "CF_WORKER_ROUTE", "DHCID", "IMPORT_TRANSFORM", "LOC", "SSHFP", "TXT":
// Do nothing. (IP address or case sensitive target)
case "SOA":
if r.target != "DEFAULT_NOT_SET." {
@ -619,7 +619,7 @@ func CanonicalizeTargets(recs []*RecordConfig, origin string) {
case "AKAMAICDN", "ANAME", "CNAME", "DS", "MX", "NS", "NAPTR", "PTR", "SRV":
// Target is a hostname that might be a shortname. Turn it into a FQDN.
r.target = dnsutil.AddOrigin(r.target, originFQDN)
case "A", "ALIAS", "CAA", "CF_REDIRECT", "CF_TEMP_REDIRECT", "CF_WORKER_ROUTE", "IMPORT_TRANSFORM", "LOC", "SSHFP", "TLSA", "TXT":
case "A", "ALIAS", "CAA", "DHCID", "CF_REDIRECT", "CF_TEMP_REDIRECT", "CF_WORKER_ROUTE", "IMPORT_TRANSFORM", "LOC", "SSHFP", "TLSA", "TXT":
// Do nothing.
case "SOA":
if r.target != "DEFAULT_NOT_SET." {

View file

@ -59,6 +59,8 @@ func (rc *RecordConfig) PopulateFromString(rtype, contents, origin string) error
return rc.SetTargetCAAString(contents)
case "DS":
return rc.SetTargetDSString(contents)
case "DHCID":
return rc.SetTarget(contents)
case "LOC":
return rc.SetTargetLOCString(origin, contents)
case "MX":

View file

@ -61,6 +61,7 @@ func validateRecordTypes(rec *models.RecordConfig, domain string, pTypes []strin
"ALIAS": false,
"CAA": true,
"CNAME": true,
"DHCID": true,
"DS": true,
"IMPORT_TRANSFORM": false,
"LOC": true,
@ -73,7 +74,6 @@ func validateRecordTypes(rec *models.RecordConfig, domain string, pTypes []strin
"SSHFP": true,
"TLSA": true,
"TXT": true,
"DHCID": true,
}
_, ok := validTypes[rec.Type]
if !ok {

View file

@ -272,6 +272,7 @@ func TestWriteZoneFileEach(t *testing.T) {
d = append(d, mustNewRR(`_443._tcp.bosun.org. 300 IN TLSA 3 1 1 abcdef0`)) // Label must be _port._proto
d = append(d, mustNewRR(`sub.bosun.org. 300 IN NS bosun.org.`)) // Must be a label with no other records.
d = append(d, mustNewRR(`x.bosun.org. 300 IN CNAME bosun.org.`)) // Must be a label with no other records.
d = append(d, mustNewRR(`bosun.org. 300 IN DHCID AAIBY2/AuCccgoJbsaxcQc9TUapptP69lOjxfNuVAA2kjEA=`))
buf := &bytes.Buffer{}
WriteZoneFileRR(buf, d, "bosun.org")
if buf.String() != testdataZFEach {
@ -289,6 +290,7 @@ var testdataZFEach = `$TTL 300
IN SRV 10 10 9999 foo.com.
IN TXT "my text"
IN CAA 0 issue "letsencrypt.org"
IN DHCID AAIBY2/AuCccgoJbsaxcQc9TUapptP69lOjxfNuVAA2kjEA=
4.5 IN PTR y.bosun.org.
_443._tcp IN TLSA 3 1 1 abcdef0
sub IN NS bosun.org.

View file

@ -14,26 +14,26 @@ func _() {
_ = x[CanUseAlias-3]
_ = x[CanUseAzureAlias-4]
_ = x[CanUseCAA-5]
_ = x[CanUseDS-6]
_ = x[CanUseDSForChildren-7]
_ = x[CanUseLOC-8]
_ = x[CanUseNAPTR-9]
_ = x[CanUsePTR-10]
_ = x[CanUseRoute53Alias-11]
_ = x[CanUseSOA-12]
_ = x[CanUseSRV-13]
_ = x[CanUseSSHFP-14]
_ = x[CanUseTLSA-15]
_ = x[CantUseNOPURGE-16]
_ = x[DocCreateDomains-17]
_ = x[DocDualHost-18]
_ = x[DocOfficiallySupported-19]
_ = x[CanUseDHCID-20]
_ = x[CanUseDHCID-6]
_ = x[CanUseDS-7]
_ = x[CanUseDSForChildren-8]
_ = x[CanUseLOC-9]
_ = x[CanUseNAPTR-10]
_ = x[CanUsePTR-11]
_ = x[CanUseRoute53Alias-12]
_ = x[CanUseSOA-13]
_ = x[CanUseSRV-14]
_ = x[CanUseSSHFP-15]
_ = x[CanUseTLSA-16]
_ = x[CantUseNOPURGE-17]
_ = x[DocCreateDomains-18]
_ = x[DocDualHost-19]
_ = x[DocOfficiallySupported-20]
}
const _Capability_name = "CanAutoDNSSECCanGetZonesCanUseAKAMAICDNCanUseAliasCanUseAzureAliasCanUseCAACanUseDSCanUseDSForChildrenCanUseLOCCanUseNAPTRCanUsePTRCanUseRoute53AliasCanUseSOACanUseSRVCanUseSSHFPCanUseTLSACantUseNOPURGEDocCreateDomainsDocDualHostDocOfficiallySupportedCanUseDHCID"
const _Capability_name = "CanAutoDNSSECCanGetZonesCanUseAKAMAICDNCanUseAliasCanUseAzureAliasCanUseCAACanUseDHCIDCanUseDSCanUseDSForChildrenCanUseLOCCanUseNAPTRCanUsePTRCanUseRoute53AliasCanUseSOACanUseSRVCanUseSSHFPCanUseTLSACantUseNOPURGEDocCreateDomainsDocDualHostDocOfficiallySupported"
var _Capability_index = [...]uint16{0, 13, 24, 39, 50, 66, 75, 83, 102, 111, 122, 131, 149, 158, 167, 178, 188, 202, 218, 229, 251, 262}
var _Capability_index = [...]uint16{0, 13, 24, 39, 50, 66, 75, 86, 94, 113, 122, 133, 142, 160, 169, 178, 189, 199, 213, 229, 240, 262}
func (i Capability) String() string {
if i >= Capability(len(_Capability_index)-1) {