]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix parsing literal IPv6 address with zone identifier in builtin dns stub resolver
authorMikio Hara <mikioh.mikioh@gmail.com>
Thu, 4 Sep 2014 03:53:51 +0000 (12:53 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Thu, 4 Sep 2014 03:53:51 +0000 (12:53 +0900)
Fixes #8619.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/132560043

src/pkg/net/dnsconfig_unix.go
src/pkg/net/dnsconfig_unix_test.go
src/pkg/net/testdata/resolv.conf

index d046b1107a3d2b5fa92a66611c5daea3e411417e..ebb6e673f1e53d345ca7f4280d221218f538055f 100644 (file)
@@ -42,7 +42,9 @@ func dnsReadConfig(filename string) (*dnsConfig, error) {
                                // One more check: make sure server name is
                                // just an IP address.  Otherwise we need DNS
                                // to look it up.
-                               if ParseIP(f[1]) != nil {
+                               if parseIPv4(f[1]) != nil {
+                                       conf.servers = append(conf.servers, f[1])
+                               } else if ip, _ := parseIPv6(f[1], true); ip != nil {
                                        conf.servers = append(conf.servers, f[1])
                                }
                        }
index 972f8cebe5fc65ddf78390732a6da38cb6309a86..94fb0c32e24a986db7d60b64d5354cc279b5ede2 100644 (file)
@@ -18,7 +18,7 @@ var dnsReadConfigTests = []struct {
        {
                name: "testdata/resolv.conf",
                conf: dnsConfig{
-                       servers:  []string{"8.8.8.8", "2001:4860:4860::8888"},
+                       servers:  []string{"8.8.8.8", "2001:4860:4860::8888", "fe80::1%lo0"},
                        search:   []string{"localdomain"},
                        ndots:    5,
                        timeout:  10,
index 3413bed1543251c4d5f7921ded8f34621fb11011..04e87eed03ff0a983de58cbe56388268d03ffd8d 100644 (file)
@@ -3,5 +3,6 @@
 domain localdomain
 nameserver 8.8.8.8
 nameserver 2001:4860:4860::8888
+nameserver fe80::1%lo0
 options ndots:5 timeout:10 attempts:3 rotate
 options attempts 3