StackExchange / dnscontrol

Infrastructure as code for DNS!
https://dnscontrol.org/
MIT License
3.11k stars 396 forks source link

Refactor Punycode (IDNA/ACE) handling #2097

Open tlimoncelli opened 1 year ago

tlimoncelli commented 1 year ago

IDNA is something that needs to be fixed in DNSControl. Currently it takes the string from dnsconfig.js and convert it by calling dc.Punycode(). At that point we lose the original.

A better way would be: The DomainConfig struct should store the original string from dnsconfig.js and the string converted to punycode. (Maybe call the punycode version .Name and the Unicode version .NameUnicode?) It should then use the original for displaying to the users and the punycode for everything else.

Or, if we're lazy we can just output "Domain {.NameUnicode} being converted to {.Name}" once and refer to the punycode for all other output.

tlimoncelli commented 1 year ago

The IDNA part of dnscontrol is kind of a mess.

First, I must confess that I'm not an expert here. I had to look up what ACE-encoding it just now. Please correct me if I use any terminology incorrectly.

The way things work now: Users can put Unicode in dnsconfig.js. The providers call dc.Punycode() which converts everything (zone names, labels, targets) to ACE-encoded (i.e. xn--bcher-kva) strings. After that all code assumes everything is ASCII. The "preview/push" output is all ASCII (I think).

The problem I see are:

I'm not 100% sure what the best way forward is. Some thoughts:

tlimoncelli commented 10 months ago

dkim1970 writes:

I would say this RFC covers the "opinions" about how IDN should be handled in applications. https://datatracker.ietf.org/doc/rfc3490/

More about IDN can be found by this author: https://datatracker.ietf.org/person/paf@paftech.se

tlimoncelli commented 10 months ago

Thanks, @dkim1970, for those URLs. I read rfc3490 and now I feel much more confident about what we should do:

My proposal:

dkim1970 commented 10 months ago

@tlimoncelli no worries happy to be of help. I agree with all your point on how a IDN domain should be handle by DNSControl from a users point of view and how the providers should conform to being force to accept that dc.Punycode() is run by DNSControl.