Commit f4034164 authored by Mikio Hara's avatar Mikio Hara

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
parent 93805d71
...@@ -42,7 +42,9 @@ func dnsReadConfig(filename string) (*dnsConfig, error) { ...@@ -42,7 +42,9 @@ func dnsReadConfig(filename string) (*dnsConfig, error) {
// One more check: make sure server name is // One more check: make sure server name is
// just an IP address. Otherwise we need DNS // just an IP address. Otherwise we need DNS
// to look it up. // 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]) conf.servers = append(conf.servers, f[1])
} }
} }
......
...@@ -18,7 +18,7 @@ var dnsReadConfigTests = []struct { ...@@ -18,7 +18,7 @@ var dnsReadConfigTests = []struct {
{ {
name: "testdata/resolv.conf", name: "testdata/resolv.conf",
conf: dnsConfig{ 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"}, search: []string{"localdomain"},
ndots: 5, ndots: 5,
timeout: 10, timeout: 10,
......
...@@ -3,5 +3,6 @@ ...@@ -3,5 +3,6 @@
domain localdomain domain localdomain
nameserver 8.8.8.8 nameserver 8.8.8.8
nameserver 2001:4860:4860::8888 nameserver 2001:4860:4860::8888
nameserver fe80::1%lo0
options ndots:5 timeout:10 attempts:3 rotate options ndots:5 timeout:10 attempts:3 rotate
options attempts 3 options attempts 3
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment