Skip to content

Commit 2c56f68

Browse files
authoredFeb 14, 2025··
CLOUDFLAREAPI: Future-proof how ALIAS is handled (#3436)
1 parent 2c4cc0c commit 2c56f68

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed
 

‎providers/cloudflare/cloudflareProvider.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,13 @@ func checkProxyVal(v string) (string, error) {
443443
}
444444

445445
func (c *cloudflareProvider) preprocessConfig(dc *models.DomainConfig) error {
446+
447+
for _, rec := range dc.Records {
448+
if rec.Type == "ALIAS" {
449+
rec.Type = "CNAME"
450+
}
451+
}
452+
446453
// Determine the default proxy setting.
447454
var defProxy string
448455
var err error
@@ -811,6 +818,12 @@ func stringDefault(value interface{}, def string) string {
811818
}
812819

813820
func (c *cloudflareProvider) nativeToRecord(domain string, cr cloudflare.DNSRecord) (*models.RecordConfig, error) {
821+
822+
// workaround for https://github.com/StackExchange/dnscontrol/issues/446
823+
if cr.Type == "SPF" {
824+
cr.Type = "TXT"
825+
}
826+
814827
// normalize cname,mx,ns records with dots to be consistent with our config format.
815828
if cr.Type == "ALIAS" || cr.Type == "CNAME" || cr.Type == "MX" || cr.Type == "NS" || cr.Type == "PTR" {
816829
if cr.Content != "." {
@@ -825,11 +838,6 @@ func (c *cloudflareProvider) nativeToRecord(domain string, cr cloudflare.DNSReco
825838
}
826839
rc.SetLabelFromFQDN(cr.Name, domain)
827840

828-
// workaround for https://github.com/StackExchange/dnscontrol/issues/446
829-
if cr.Type == "SPF" {
830-
cr.Type = "TXT"
831-
}
832-
833841
if cr.Type == "A" || cr.Type == "AAAA" || cr.Type == "CNAME" {
834842
if cr.Proxied != nil {
835843
if *(cr.Proxied) {

0 commit comments

Comments
 (0)
Please sign in to comment.