StackExchange / dnscontrol

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

Standardize IPv6 Format #25

Closed captncraig closed 7 years ago

captncraig commented 7 years ago

If I make a AAAA record: AAAA("@","2001:0db8:85a3:0000:0000:8a2e:0370:7334"), I can create it in gcloud no problem.

I do always get a modification though: MODIFY AAAA example5555qwerty.com: (2001:db8:85a3::8a2e:370:7334 300) -> (2001:0db8:85a3:0000:0000:8a2e:0370:7334 300)

Because gcloud stores and returns it in the minified format. I propose as part of the validation/normalization phase, we minimize all ipv6 addresses. That will become our "standard" format. If any provider has issue with that, we will handle it in the provider itself.

tlimoncelli commented 7 years ago

I agree that we should represent IPv6 addresses in a minified form when putting it in JSON, printing, or representing them in unicode.

However IIRC we store IPv6 values internally as a 16-byte string (actually a net.Addr). Don't we?

captncraig commented 7 years ago

For the AAAA records, I believe we only ever treat them as strings. I don't believe we do any kind of conversion at any point.

The solution is really:

  1. Use net.ParseIP to get a net.IP.
  2. Ensure no errors, and that it is a valid v6 ip
  3. Use String() method on it as new target.

We do not currently have any facility for working with v6 in the js, and they should be transmitted as strings.

mhenderson-so commented 7 years ago

I've never actually seen an IP address with 0000:0000 in the wild - I've only ever seen them shortened with the :: syntax (also don't forget that an IP address can end with ::)

Although the idea of an IP address storage ultimately being a string makes me shudder a bit, I think for this purpose it's OK. Even if we do the 3-step "Parse, validate, string()", I think that should work. At least the data we sent via the APIs will be consistent

Mark Henderson Site Reliability Engineer

110 William St., 28th Floor New York, NY 10038

On Tue, Jan 10, 2017 at 8:33 PM, Craig Peterson notifications@github.com wrote:

For the AAAA records, I believe we only ever treat them as strings. I don't believe we do any kind of conversion at any point.

The solution is really:

  1. Use net.ParseIP to get a net.IP.
  2. Ensure no errors, and that it is a valid v6 ip
  3. Use String() method on it as new target.

We do not currently have any facility for working with v6 in the js, and they should be transmitted as strings.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/StackExchange/dnscontrol/issues/25#issuecomment-271752563, or mute the thread https://github.com/notifications/unsubscribe-auth/AOGs74UtpT3nN3sRcuRYmOSM9TKNzXavks5rRDF1gaJpZM4LgBqR .

tlimoncelli commented 7 years ago

I agree: Continue to treat them as strings in JS; for golang code do the "Parse, validate, string()" process to get the canonical format (it works https://play.golang.org/p/60ZTueSpsO ).

tlimoncelli commented 7 years ago

I believe that if we minified the IPv6 addresses at the validation/normalization step, then future API calls will do the right thing. It is just dumb luck, but I think it will work.

Can someone with a domain on gcloud test to see if c15c9487f6150769ce1ee69aad28835761e91213 fixes the problem?

tlimoncelli commented 7 years ago

Fixed in 6a80f71d667ff4bad6ab576c3ba7c4ca7ab9d46d