This commit is contained in:
Thomas Limoncelli 2025-11-21 11:50:30 -05:00
parent c7f625a502
commit 507dc4e0ad
No known key found for this signature in database
3 changed files with 28 additions and 10 deletions

View file

@ -14,6 +14,7 @@ import (
"github.com/StackExchange/dnscontrol/v4/pkg/version"
"github.com/fatih/color"
"github.com/urfave/cli/v2"
"golang.org/x/net/idna"
)
// categories of commands
@ -308,7 +309,7 @@ func (args *FilterArgs) flags() []cli.Flag {
// domain is in the list, accounting for wildcards and tags.
func domainInList(domain string, list []string) bool {
for _, item := range list {
if item == domain {
if downgradeIDNA(item) == downgradeIDNA(domain) {
return true
}
if strings.HasPrefix(item, "*") && strings.HasSuffix(domain, item[1:]) {
@ -316,6 +317,11 @@ func domainInList(domain string, list []string) bool {
}
filterDom, filterTag, isFilterTagged := strings.Cut(item, "!")
splitDom, domainTag, isDomainTagged := strings.Cut(domain, "!")
splitDom = downgradeIDNA(splitDom)
filterDom = downgradeIDNA(filterDom)
//fmt.Printf("###DEBUG: does %q == %q? %v\n", splitDom, filterDom, splitDom == filterDom)
if splitDom == filterDom {
if isDomainTagged {
if filterTag == "*" {
@ -339,3 +345,11 @@ func domainInList(domain string, list []string) bool {
}
return false
}
func downgradeIDNA(s string) string {
u, err := idna.ToASCII(s)
if err != nil {
return s // There was a problem. Abort and return the original.
}
return u
}

View file

@ -420,6 +420,7 @@ func prun(args PPreviewArgs, push bool, interactive bool, out printer.CLI, repor
// filter. The filter string is a comma-separated list of domain names. If the
// filter string is empty or "all", all domains are returned.
func whichZonesToProcess(domains []*models.DomainConfig, filter string) []*models.DomainConfig {
fmt.Printf("###DEBUG: whichZonesToProcess filter=%q\n", filter)
if filter == "" || filter == "all" {
return domains
}

View file

@ -354,21 +354,24 @@ type Warning struct {
// ValidateAndNormalizeConfig performs and normalization and/or validation of the IR.
func ValidateAndNormalizeConfig(config *models.DNSConfig) (errs []error) {
// This is a horrible hack. We need to redo IDN processing someday.
// For now, we just convert everything to punycode at the earliest point, which is here.
for _, domain := range config.Domains {
// Convert domain name to punycode.
var err error
domain.Name, err = idna.ToASCII(domain.Name)
if err != nil {
return []error{fmt.Errorf("Can not convert domain %q to IDN: %w", domain.Name, err)}
}
}
err := processSplitHorizonDomains(config)
if err != nil {
return []error{err}
}
for _, domain := range config.Domains {
// Convert domain name to punycode.
// In the future, we should do something more sophisticated like having a .Name/.NameUnicode/.NameIDN so that users can see.
var err error
domain.Name, err = idna.ToASCII(domain.Name)
if err != nil {
return []error{fmt.Errorf("Can not convert domain %q to IDN: %w", domain.Name, err)}
}
pTypes := []string{}
for _, provider := range domain.DNSProviderInstances {
pType := provider.ProviderType