mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-11-10 16:30:38 +08:00
CLOUDFLAREAPI: Bugfix: Fix misaligned CF_SINGLE_REDIRECT validation (#3042)
This commit is contained in:
parent
cff63b5d75
commit
571eaf0244
4 changed files with 4 additions and 6 deletions
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/StackExchange/dnscontrol/v4/models"
|
"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/pkg/transform"
|
||||||
"github.com/StackExchange/dnscontrol/v4/providers"
|
"github.com/StackExchange/dnscontrol/v4/providers"
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
|
|
@ -79,7 +78,7 @@ func validateRecordTypes(rec *models.RecordConfig, domain string, pTypes []strin
|
||||||
"TXT": true,
|
"TXT": true,
|
||||||
}
|
}
|
||||||
_, ok := validTypes[rec.Type]
|
_, ok := validTypes[rec.Type]
|
||||||
if !ok || rtypecontrol.IsValid(rec.Type) {
|
if !ok {
|
||||||
cType := providers.GetCustomRecordType(rec.Type)
|
cType := providers.GetCustomRecordType(rec.Type)
|
||||||
if cType == nil {
|
if cType == nil {
|
||||||
return fmt.Errorf("unsupported record type (%v) domain=%v name=%v", rec.Type, domain, rec.GetLabel())
|
return fmt.Errorf("unsupported record type (%v) domain=%v name=%v", rec.Type, domain, rec.GetLabel())
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package rtypecontrol
|
package rtypecontrol
|
||||||
|
|
||||||
|
import "github.com/StackExchange/dnscontrol/v4/providers"
|
||||||
|
|
||||||
var validTypes = map[string]struct{}{}
|
var validTypes = map[string]struct{}{}
|
||||||
|
|
||||||
func Register(t string) {
|
func Register(t string) {
|
||||||
|
|
@ -10,6 +12,7 @@ func Register(t string) {
|
||||||
|
|
||||||
validTypes[t] = struct{}{}
|
validTypes[t] = struct{}{}
|
||||||
|
|
||||||
|
providers.RegisterCustomRecordType(t, "", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsValid(t string) bool {
|
func IsValid(t string) bool {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ func PostProcess(domains []*models.DomainConfig) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
for _, dc := range domains {
|
for _, dc := range domains {
|
||||||
//fmt.Printf("DOMAIN: %d %s\n", len(dc.Records), dc.Name)
|
|
||||||
|
|
||||||
for _, rawRec := range dc.RawRecords {
|
for _, rawRec := range dc.RawRecords {
|
||||||
rec := &models.RecordConfig{
|
rec := &models.RecordConfig{
|
||||||
|
|
@ -38,7 +37,6 @@ func PostProcess(domains []*models.DomainConfig) error {
|
||||||
switch rawRec.Type {
|
switch rawRec.Type {
|
||||||
|
|
||||||
case "CLOUDFLAREAPI_SINGLE_REDIRECT":
|
case "CLOUDFLAREAPI_SINGLE_REDIRECT":
|
||||||
rec.Name = rawRec.Args[0].(string)
|
|
||||||
err = cfsingleredirect.FromRaw(rec, rawRec.Args)
|
err = cfsingleredirect.FromRaw(rec, rawRec.Args)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,6 @@ func init() {
|
||||||
RecordAuditor: AuditRecords,
|
RecordAuditor: AuditRecords,
|
||||||
}
|
}
|
||||||
providers.RegisterDomainServiceProviderType("CLOUDFLAREAPI", fns, features)
|
providers.RegisterDomainServiceProviderType("CLOUDFLAREAPI", fns, features)
|
||||||
providers.RegisterCustomRecordType("rtype", "CLOUDFLAREAPI", "")
|
|
||||||
//providers.RegisterCustomRecordType("CF_SINGLE_REDIRECT", "CLOUDFLAREAPI", "")
|
|
||||||
providers.RegisterCustomRecordType("CF_REDIRECT", "CLOUDFLAREAPI", "")
|
providers.RegisterCustomRecordType("CF_REDIRECT", "CLOUDFLAREAPI", "")
|
||||||
providers.RegisterCustomRecordType("CF_TEMP_REDIRECT", "CLOUDFLAREAPI", "")
|
providers.RegisterCustomRecordType("CF_TEMP_REDIRECT", "CLOUDFLAREAPI", "")
|
||||||
providers.RegisterCustomRecordType("CF_WORKER_ROUTE", "CLOUDFLAREAPI", "")
|
providers.RegisterCustomRecordType("CF_WORKER_ROUTE", "CLOUDFLAREAPI", "")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue