mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2026-01-06 16:24:15 +08:00
fixup!
This commit is contained in:
parent
c7f625a502
commit
507dc4e0ad
3 changed files with 28 additions and 10 deletions
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/StackExchange/dnscontrol/v4/pkg/version"
|
"github.com/StackExchange/dnscontrol/v4/pkg/version"
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
"golang.org/x/net/idna"
|
||||||
)
|
)
|
||||||
|
|
||||||
// categories of commands
|
// categories of commands
|
||||||
|
|
@ -308,7 +309,7 @@ func (args *FilterArgs) flags() []cli.Flag {
|
||||||
// domain is in the list, accounting for wildcards and tags.
|
// domain is in the list, accounting for wildcards and tags.
|
||||||
func domainInList(domain string, list []string) bool {
|
func domainInList(domain string, list []string) bool {
|
||||||
for _, item := range list {
|
for _, item := range list {
|
||||||
if item == domain {
|
if downgradeIDNA(item) == downgradeIDNA(domain) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(item, "*") && strings.HasSuffix(domain, item[1:]) {
|
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, "!")
|
filterDom, filterTag, isFilterTagged := strings.Cut(item, "!")
|
||||||
splitDom, domainTag, isDomainTagged := strings.Cut(domain, "!")
|
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 splitDom == filterDom {
|
||||||
if isDomainTagged {
|
if isDomainTagged {
|
||||||
if filterTag == "*" {
|
if filterTag == "*" {
|
||||||
|
|
@ -339,3 +345,11 @@ func domainInList(domain string, list []string) bool {
|
||||||
}
|
}
|
||||||
return false
|
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
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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. The filter string is a comma-separated list of domain names. If the
|
||||||
// filter string is empty or "all", all domains are returned.
|
// filter string is empty or "all", all domains are returned.
|
||||||
func whichZonesToProcess(domains []*models.DomainConfig, filter string) []*models.DomainConfig {
|
func whichZonesToProcess(domains []*models.DomainConfig, filter string) []*models.DomainConfig {
|
||||||
|
fmt.Printf("###DEBUG: whichZonesToProcess filter=%q\n", filter)
|
||||||
if filter == "" || filter == "all" {
|
if filter == "" || filter == "all" {
|
||||||
return domains
|
return domains
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -354,21 +354,24 @@ type Warning struct {
|
||||||
|
|
||||||
// ValidateAndNormalizeConfig performs and normalization and/or validation of the IR.
|
// ValidateAndNormalizeConfig performs and normalization and/or validation of the IR.
|
||||||
func ValidateAndNormalizeConfig(config *models.DNSConfig) (errs []error) {
|
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)
|
err := processSplitHorizonDomains(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []error{err}
|
return []error{err}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, domain := range config.Domains {
|
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{}
|
pTypes := []string{}
|
||||||
for _, provider := range domain.DNSProviderInstances {
|
for _, provider := range domain.DNSProviderInstances {
|
||||||
pType := provider.ProviderType
|
pType := provider.ProviderType
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue