diff options
| author | Mikio Hara <mikioh.mikioh@gmail.com> | 2014-09-04 12:53:51 +0900 |
|---|---|---|
| committer | Mikio Hara <mikioh.mikioh@gmail.com> | 2014-09-04 12:53:51 +0900 |
| commit | f40341643cc254aa4e00baf455aa85684957cd92 (patch) | |
| tree | f4bae25cba98e4e9bd263a03061b1b09fbf66dac /src/pkg | |
| parent | 93805d711ce1d489af032c617a1ae19ef07922e4 (diff) | |
| download | go-f40341643cc254aa4e00baf455aa85684957cd92.tar.xz | |
net: fix parsing literal IPv6 address with zone identifier in builtin dns stub resolver
Fixes #8619.
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/132560043
Diffstat (limited to 'src/pkg')
| -rw-r--r-- | src/pkg/net/dnsconfig_unix.go | 4 | ||||
| -rw-r--r-- | src/pkg/net/dnsconfig_unix_test.go | 2 | ||||
| -rw-r--r-- | src/pkg/net/testdata/resolv.conf | 1 |
3 files changed, 5 insertions, 2 deletions
diff --git a/src/pkg/net/dnsconfig_unix.go b/src/pkg/net/dnsconfig_unix.go index d046b1107a..ebb6e673f1 100644 --- a/src/pkg/net/dnsconfig_unix.go +++ b/src/pkg/net/dnsconfig_unix.go @@ -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]) } } diff --git a/src/pkg/net/dnsconfig_unix_test.go b/src/pkg/net/dnsconfig_unix_test.go index 972f8cebe5..94fb0c32e2 100644 --- a/src/pkg/net/dnsconfig_unix_test.go +++ b/src/pkg/net/dnsconfig_unix_test.go @@ -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, diff --git a/src/pkg/net/testdata/resolv.conf b/src/pkg/net/testdata/resolv.conf index 3413bed154..04e87eed03 100644 --- a/src/pkg/net/testdata/resolv.conf +++ b/src/pkg/net/testdata/resolv.conf @@ -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 |
