CLOUDFLAREAPI: Bugfix: Fix misaligned CF_SINGLE_REDIRECT validation (#3042)

This commit is contained in:
Tom Limoncelli 2024-07-09 14:32:37 -04:00 committed by GitHub
parent cff63b5d75
commit 571eaf0244
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 4 additions and 6 deletions

View file

@ -7,7 +7,6 @@ import (
"strings"
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/rtypecontrol"
"github.com/StackExchange/dnscontrol/v4/pkg/transform"
"github.com/StackExchange/dnscontrol/v4/providers"
"github.com/miekg/dns"
@ -79,7 +78,7 @@ func validateRecordTypes(rec *models.RecordConfig, domain string, pTypes []strin
"TXT": true,
}
_, ok := validTypes[rec.Type]
if !ok || rtypecontrol.IsValid(rec.Type) {
if !ok {
cType := providers.GetCustomRecordType(rec.Type)
if cType == nil {
return fmt.Errorf("unsupported record type (%v) domain=%v name=%v", rec.Type, domain, rec.GetLabel())

View file

@ -1,5 +1,7 @@
package rtypecontrol
import "github.com/StackExchange/dnscontrol/v4/providers"
var validTypes = map[string]struct{}{}
func Register(t string) {
@ -10,6 +12,7 @@ func Register(t string) {
validTypes[t] = struct{}{}
providers.RegisterCustomRecordType(t, "", "")
}
func IsValid(t string) bool {

View file

@ -12,7 +12,6 @@ func PostProcess(domains []*models.DomainConfig) error {
var err error
for _, dc := range domains {
//fmt.Printf("DOMAIN: %d %s\n", len(dc.Records), dc.Name)
for _, rawRec := range dc.RawRecords {
rec := &models.RecordConfig{
@ -38,7 +37,6 @@ func PostProcess(domains []*models.DomainConfig) error {
switch rawRec.Type {
case "CLOUDFLAREAPI_SINGLE_REDIRECT":
rec.Name = rawRec.Args[0].(string)
err = cfsingleredirect.FromRaw(rec, rawRec.Args)
default:

View file

@ -69,8 +69,6 @@ func init() {
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("CLOUDFLAREAPI", fns, features)
providers.RegisterCustomRecordType("rtype", "CLOUDFLAREAPI", "")
//providers.RegisterCustomRecordType("CF_SINGLE_REDIRECT", "CLOUDFLAREAPI", "")
providers.RegisterCustomRecordType("CF_REDIRECT", "CLOUDFLAREAPI", "")
providers.RegisterCustomRecordType("CF_TEMP_REDIRECT", "CLOUDFLAREAPI", "")
providers.RegisterCustomRecordType("CF_WORKER_ROUTE", "CLOUDFLAREAPI", "")