Skip to content

Commit f403416

Browse files
committed
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
1 parent 93805d7 commit f403416

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/pkg/net/dnsconfig_unix.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ func dnsReadConfig(filename string) (*dnsConfig, error) {
4242
// One more check: make sure server name is
4343
// just an IP address. Otherwise we need DNS
4444
// to look it up.
45-
if ParseIP(f[1]) != nil {
45+
if parseIPv4(f[1]) != nil {
46+
conf.servers = append(conf.servers, f[1])
47+
} else if ip, _ := parseIPv6(f[1], true); ip != nil {
4648
conf.servers = append(conf.servers, f[1])
4749
}
4850
}

src/pkg/net/dnsconfig_unix_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var dnsReadConfigTests = []struct {
1818
{
1919
name: "testdata/resolv.conf",
2020
conf: dnsConfig{
21-
servers: []string{"8.8.8.8", "2001:4860:4860::8888"},
21+
servers: []string{"8.8.8.8", "2001:4860:4860::8888", "fe80::1%lo0"},
2222
search: []string{"localdomain"},
2323
ndots: 5,
2424
timeout: 10,

src/pkg/net/testdata/resolv.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
domain localdomain
44
nameserver 8.8.8.8
55
nameserver 2001:4860:4860::8888
6+
nameserver fe80::1%lo0
67
options ndots:5 timeout:10 attempts:3 rotate
78
options attempts 3

0 commit comments

Comments
 (0)