CLOUDFLARE: Support unicode domains (#2466)

Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
Brian Hartvigsen 2023-08-17 09:41:52 -06:00 committed by GitHub
parent 89cc1f0667
commit 5d9b82e917
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -3,6 +3,7 @@ package cloudflare
import (
"encoding/json"
"fmt"
"golang.org/x/net/idna"
"net"
"os"
"strconv"
@ -485,8 +486,14 @@ func (c *cloudflareProvider) mkDeleteCorrection(recType string, origRec any, dom
func checkNSModifications(dc *models.DomainConfig) {
newList := make([]*models.RecordConfig, 0, len(dc.Records))
punyRoot, err := idna.ToASCII(dc.Name)
if err != nil {
punyRoot = dc.Name
}
for _, rec := range dc.Records {
if rec.Type == "NS" && rec.GetLabelFQDN() == dc.Name {
if rec.Type == "NS" && rec.GetLabelFQDN() == punyRoot {
if !strings.HasSuffix(rec.GetTargetField(), ".ns.cloudflare.com.") {
printer.Warnf("cloudflare does not support modifying NS records on base domain. %s will not be added.\n", rec.GetTargetField())
}

View file

@ -3,6 +3,7 @@ package cloudflare
import (
"context"
"fmt"
"golang.org/x/net/idna"
"strconv"
"strings"
@ -20,6 +21,10 @@ func (c *cloudflareProvider) fetchDomainList() error {
}
for _, zone := range zones {
if encoded, err := idna.ToASCII(zone.Name); err == nil && encoded != zone.Name {
c.domainIndex[encoded] = zone.ID
c.nameservers[encoded] = append(c.nameservers[encoded], zone.NameServers...)
}
c.domainIndex[zone.Name] = zone.ID
c.nameservers[zone.Name] = append(c.nameservers[zone.Name], zone.NameServers...)
}