mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-12-09 21:55:57 +08:00
m
This commit is contained in:
parent
0315c8499b
commit
d0604a24d1
3 changed files with 29 additions and 8 deletions
|
|
@ -18,7 +18,10 @@ const (
|
|||
|
||||
// DomainConfig describes a DNS domain (technically a DNS zone).
|
||||
type DomainConfig struct {
|
||||
Name string `json:"name"` // NO trailing "."
|
||||
Name string `json:"name"` // NO trailing "." Converted to IDN (punycode) early in the pipeline.
|
||||
NameRaw string `json:"-"` // name as entered by user in dnsconfig.js
|
||||
NameUnicode string `json:"-"` // name in Unicode format
|
||||
|
||||
RegistrarName string `json:"registrar"`
|
||||
DNSProviderNames map[string]int `json:"dnsProviders"`
|
||||
|
||||
|
|
|
|||
|
|
@ -355,15 +355,29 @@ 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.
|
||||
// This should probably be done elsewhere (maybe where we first ingest a domain).
|
||||
// Convert all domain names to punycode.
|
||||
for _, domain := range config.Domains {
|
||||
// Convert domain name to punycode.
|
||||
var err error
|
||||
domain.Name, err = idna.ToASCII(domain.Name)
|
||||
|
||||
// Create the .NameRaw field.
|
||||
domain.NameRaw = domain.Name
|
||||
idn, err := idna.ToASCII(domain.Name)
|
||||
if err != nil {
|
||||
return []error{fmt.Errorf("Can not convert domain %q to IDN: %w", domain.Name, err)}
|
||||
}
|
||||
if idn != domain.NameRaw {
|
||||
domain.Name = idn
|
||||
}
|
||||
|
||||
// Create the .NameUnicode field.
|
||||
domain.NameUnicode = domain.Name
|
||||
uni, err := idna.ToUnicode(domain.Name)
|
||||
if err != nil {
|
||||
return []error{fmt.Errorf("Can not convert domain %q to Unicode: %w", domain.Name, err)}
|
||||
}
|
||||
if uni != domain.NameUnicode {
|
||||
domain.NameUnicode = idn
|
||||
}
|
||||
}
|
||||
|
||||
err := processSplitHorizonDomains(config)
|
||||
|
|
|
|||
|
|
@ -89,8 +89,12 @@ type ConsolePrinter struct {
|
|||
}
|
||||
|
||||
// StartDomain is called at the start of each domain.
|
||||
func (c ConsolePrinter) StartDomain(domain string) {
|
||||
fmt.Fprintf(c.Writer, "******************** Domain: %s\n", domain)
|
||||
func (c ConsolePrinter) StartDomain(domainIDN, domainUnicode string) {
|
||||
if domainIDN == domainUnicode {
|
||||
fmt.Fprintf(c.Writer, "******************** Domain: %s\n", domainIDN)
|
||||
} else {
|
||||
fmt.Fprintf(c.Writer, "******************** Domain: %s (%s)\n", domainIDN, domainUnicode)
|
||||
}
|
||||
}
|
||||
|
||||
// PrintCorrection is called to print/format each correction.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue