From a3ed1dc6b2eb2abc181340c57c842c21d344793d Mon Sep 17 00:00:00 2001 From: Thomas Limoncelli Date: Sun, 30 Nov 2025 11:46:27 -0500 Subject: [PATCH] wip! getting BIND to work --- .../advanced-features/debugging-with-dlv.md | 2 +- integrationTest/helpers_integration_test.go | 6 ++++++ integrationTest/integration_test.go | 7 +++++++ main.go | 1 + models/domain.go | 4 ++++ models/record.go | 16 ++++++++++++---- pkg/rtypecontrol/rtypecontrol.go | 2 +- 7 files changed, 32 insertions(+), 6 deletions(-) diff --git a/documentation/advanced-features/debugging-with-dlv.md b/documentation/advanced-features/debugging-with-dlv.md index 7d1e2662b..e69e1cace 100644 --- a/documentation/advanced-features/debugging-with-dlv.md +++ b/documentation/advanced-features/debugging-with-dlv.md @@ -11,5 +11,5 @@ dlv test github.com/StackExchange/dnscontrol/v4/pkg/diff2 -- -test.run Test_anal Debug the integration tests: ```shell -dlv test github.com/StackExchange/dnscontrol/v4/integrationTest -- -test.v -test.run ^TestDNSProviders -verbose -profile NAMEDOTCOM -start 1 -end 1 -diff2 +dlv test github.com/StackExchange/dnscontrol/v4/integrationTest -- -test.v -test.run ^TestDNSProviders -verbose -profile NAMEDOTCOM -start 1 -end 1 ``` diff --git a/integrationTest/helpers_integration_test.go b/integrationTest/helpers_integration_test.go index 29af4e085..b5a96f361 100644 --- a/integrationTest/helpers_integration_test.go +++ b/integrationTest/helpers_integration_test.go @@ -486,6 +486,12 @@ func r53alias(name, aliasType, target, evalTargetHealth string) *models.RecordCo return r } +func rp(name string, m, t string) *models.RecordConfig { + rec, err := rtypecontrol.NewRecordConfigFromRaw("RP", []any{name, m, t}, globalDC) + panicOnErr(err) + return rec +} + func smimea(name string, usage, selector, matchingtype uint8, target string) *models.RecordConfig { r := makeRec(name, target, "SMIMEA") panicOnErr(r.SetTargetSMIMEA(usage, selector, matchingtype, target)) diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index 703153326..bad4819ee 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -6,6 +6,7 @@ import ( "strings" "testing" + _ "github.com/StackExchange/dnscontrol/v4/pkg/rtype" "github.com/StackExchange/dnscontrol/v4/providers" _ "github.com/StackExchange/dnscontrol/v4/providers/_all" ) @@ -172,6 +173,12 @@ func makeTests() []*TestGroup { tc("Change MX p", mx("testmx", 100, "bar.com.")), ), + testgroup("RP", + tc("Create RP", rp("foo", "usr@example.com", "bar.com")), + tc("Create RP", rp("foo", "other@example.com", "bar.com")), + tc("Create RP", rp("foo", "other@example.com", "example.com")), + ), + // TXT // Narrative: TXT records can be very complex but we'll save those diff --git a/main.go b/main.go index 818506c76..41374316e 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "runtime/debug" "github.com/StackExchange/dnscontrol/v4/commands" + _ "github.com/StackExchange/dnscontrol/v4/pkg/rtype" "github.com/StackExchange/dnscontrol/v4/pkg/version" _ "github.com/StackExchange/dnscontrol/v4/providers/_all" "github.com/fatih/color" diff --git a/models/domain.go b/models/domain.go index 13a672ca1..fd337793b 100644 --- a/models/domain.go +++ b/models/domain.go @@ -121,6 +121,10 @@ func (dc *DomainConfig) Filter(f func(r *RecordConfig) bool) { // - Target (CNAME and MX only) func (dc *DomainConfig) Punycode() error { for _, rec := range dc.Records { + if rec.IsModernType() { + continue // Modern types handle punycode themselves. + } + // Update the label: t, err := idna.ToASCII(rec.GetLabelFQDN()) if err != nil { diff --git a/models/record.go b/models/record.go index b7fb2098e..740979b80 100644 --- a/models/record.go +++ b/models/record.go @@ -352,6 +352,11 @@ func (rc *RecordConfig) ToComparableNoTTL() string { // ToRR converts a RecordConfig to a dns.RR. func (rc *RecordConfig) ToRR() dns.RR { + // IsModernType types store standard types as dns.RR directly in rc.F. + if rr, ok := rc.F.(dns.RR); ok { + return rr + } + // Don't call this on fake types. rdtype, ok := dns.StringToType[rc.Type] if !ok { @@ -533,11 +538,14 @@ func (rc *RecordConfig) GetSVCBValue() []dns.SVCBKeyValue { func (rc *RecordConfig) IsModernType() bool { //fmt.Printf("DEBUG: IsModernType rtype=%s\n", rc.Type) - if rc.Type == "CLOUDFLAREAPI_SINGLE_REDIRECT" { - return true - } + return rc.F != nil - return false + // switch rc.Type { + // case "CLOUDFLAREAPI_SINGLE_REDIRECT", "RP": + // return true + // } + + // return false } // Records is a list of *RecordConfig. diff --git a/pkg/rtypecontrol/rtypecontrol.go b/pkg/rtypecontrol/rtypecontrol.go index 8bbdcec80..c2a916d22 100644 --- a/pkg/rtypecontrol/rtypecontrol.go +++ b/pkg/rtypecontrol/rtypecontrol.go @@ -35,7 +35,7 @@ func Register(t RType) { providers.RegisterCustomRecordType(name, "", "") } -func IsValid(name string) bool { +func IsModernType(name string) bool { _, ok := Func[name] return ok }