mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-09-11 15:44:55 +08:00
CLOUDFLARE: Support unicode domains (#2466)
Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
parent
89cc1f0667
commit
5d9b82e917
2 changed files with 13 additions and 1 deletions
|
@ -3,6 +3,7 @@ package cloudflare
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"golang.org/x/net/idna"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -485,8 +486,14 @@ func (c *cloudflareProvider) mkDeleteCorrection(recType string, origRec any, dom
|
||||||
|
|
||||||
func checkNSModifications(dc *models.DomainConfig) {
|
func checkNSModifications(dc *models.DomainConfig) {
|
||||||
newList := make([]*models.RecordConfig, 0, len(dc.Records))
|
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 {
|
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.") {
|
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())
|
printer.Warnf("cloudflare does not support modifying NS records on base domain. %s will not be added.\n", rec.GetTargetField())
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package cloudflare
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"golang.org/x/net/idna"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -20,6 +21,10 @@ func (c *cloudflareProvider) fetchDomainList() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, zone := range zones {
|
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.domainIndex[zone.Name] = zone.ID
|
||||||
c.nameservers[zone.Name] = append(c.nameservers[zone.Name], zone.NameServers...)
|
c.nameservers[zone.Name] = append(c.nameservers[zone.Name], zone.NameServers...)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue