ipv6 hostnames in brackets?

1,629 views
Skip to first unread message

Brad Fitzpatrick

unread,
Jul 31, 2014, 1:47:57 PM7/31/14
to golang-dev, Mathieu Lonjaret
I don't understand what this part of the net.Dial docs are trying to say:

"If host is a literal IPv6 address or host name, it must be enclosed in square brackets as in "[::1]:80", "[ipv6-host]:http" or "[ipv6-host%zone]:80". "

But then it goes on to list as an example:

    Dial("tcp", "google.com:http")

What if the hostname only has AAAA records and not A?

e.g. is this invalid?

    Dial("tcp", "ipv6.google.com:http")

In other words, what is a "IPv6 host name" aka "[ipv6-host]:http"?

Andrew Gerrand

unread,
Jul 31, 2014, 7:31:03 PM7/31/14
to Brad Fitzpatrick, golang-dev, Mathieu Lonjaret
I suspect (but have no evidence to support) that the sentence you quoted shouldn't say "or host name". That is, the square brackets should only apply to IPv6 addresses, not host names.

Sorry to not provide any actual information.

Brad Fitzpatrick

unread,
Jul 31, 2014, 8:59:14 PM7/31/14
to Andrew Gerrand, golang-dev, Mathieu Lonjaret
If nobody speaks up soon I'll send out a CL changing it to what I think it means and what I read the code as doing.

Andrew Gerrand

unread,
Jul 31, 2014, 9:00:33 PM7/31/14
to Brad Fitzpatrick, golang-dev, Mathieu Lonjaret

On 1 August 2014 10:59, Brad Fitzpatrick <brad...@golang.org> wrote:
what I read the code as doing.

What's that?

Devon H. O'Dell

unread,
Jul 31, 2014, 9:09:40 PM7/31/14
to Brad Fitzpatrick, Andrew Gerrand, golang-dev, Mathieu Lonjaret
2014-07-31 17:59 GMT-07:00 Brad Fitzpatrick <brad...@golang.org>:
> If nobody speaks up soon I'll send out a CL changing it to what I think it
> means and what I read the code as doing.

The wording in the docs is incorrect. If any code requires brackets
around hostnames to treat them as v6, it's wrong. RFC 4472 provides
guidance on how to handle precedence of AAAA over A records in chapter
5. Brackets are used to specify v6 addresses and unless anything has
changed, net already handles all forms of valid forms of v6 addresses.

--dho

> On Thu, Jul 31, 2014 at 4:30 PM, Andrew Gerrand <a...@golang.org> wrote:
>>
>> I suspect (but have no evidence to support) that the sentence you quoted
>> shouldn't say "or host name". That is, the square brackets should only apply
>> to IPv6 addresses, not host names.
>>
>> Sorry to not provide any actual information.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-dev+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Mikio Hara

unread,
Jul 31, 2014, 9:28:33 PM7/31/14
to Brad Fitzpatrick, Andrew Gerrand, golang-dev, Mathieu Lonjaret
On Fri, Aug 1, 2014 at 9:59 AM, Brad Fitzpatrick <brad...@golang.org> wrote:

> If nobody speaks up soon I'll send out a CL changing it to what I think it
> means and what I read the code as doing.

thanks, it's a documentation bug. i'm happy if you can fix similar
bugs on Resolve{TCP,UDP,IP}Addr.
in ABNF, they are described as the following:

Host = ( IPLiteral / IPv4address / ResolvableName ) [ ":" Port ]
IPv4address = /* snip */
IPLiteral = "[" ( IPv6address / IPv6addressWithZoneID ) "]"
ResolvableName = /* ah... DNS, mDNS or other name that can be resolved
by platform services */
IPv6address = /* snip */
IPv6addressWithZoneID = IPv6address "%" ZoneID
ZoneID = 1*( OpaqueString )
Port = *DIGIT

pma...@google.com

unread,
Aug 1, 2014, 8:47:32 PM8/1/14
to golan...@googlegroups.com, brad...@golang.org, mathieu....@gmail.com
On Thursday, July 31, 2014 4:31:03 PM UTC-7, Andrew Gerrand wrote:
I suspect (but have no evidence to support) that the sentence you quoted shouldn't say "or host name". That is, the square brackets should only apply to IPv6 addresses, not host names.

Sorry to not provide any actual information.

Right; brackets are for IPv6 addresses, not hostnames.  This currently works, but it shouldn't:

    net.Dial("tcp", "[ipv6.google.com]:80")

I think SplitHostPort() should fail if no colons exist between the brackets.

Brad Fitzpatrick

unread,
Aug 1, 2014, 9:36:43 PM8/1/14
to pma...@google.com, golang-dev, Mathieu Lonjaret
The Go 1 compatibility promise prohibits us from changing that at this point. 

Dan Kortschak

unread,
Aug 1, 2014, 10:41:40 PM8/1/14
to Brad Fitzpatrick, pma...@google.com, golang-dev, Mathieu Lonjaret
On Fri, 2014-08-01 at 18:36 -0700, Brad Fitzpatrick wrote:
> The Go 1 compatibility promise prohibits us from changing that at this
> point.

Even if it's a bug?

Brad Fitzpatrick

unread,
Aug 1, 2014, 10:46:01 PM8/1/14
to Dan Kortschak, Mathieu Lonjaret, golang-dev, pma...@google.com

Depends how severe.

Russ Cox

unread,
Aug 4, 2014, 9:25:12 PM8/4/14
to Brad Fitzpatrick, Dan Kortschak, Mathieu Lonjaret, golang-dev, pma...@google.com
I think we should leave well enough alone. Fix the docs but don't change the behavior.

Reply all
Reply to author
Forward
0 new messages