Skip to content

Commit 484f46d

Browse files
committed
net: fix dns bug reported on irc.
if suffixes don't work, check for name directly. also fixes short names like bit.ly when ndots>1. tested by tossing domain and search lines from /etc/resolv.conf Fixes #2. R=agl, agl1 CC=golang-dev https://golang.org/cl/152048
1 parent c8bb81f commit 484f46d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/pkg/net/dnsclient.go

+11
Original file line numberDiff line numberDiff line change
@@ -268,5 +268,16 @@ func LookupHost(name string) (cname string, addrs []string, err os.Error) {
268268
return;
269269
}
270270
}
271+
272+
// Last ditch effort: try unsuffixed.
273+
rname := name;
274+
if !rooted {
275+
rname += "."
276+
}
277+
addrs, err = tryOneName(cfg, rname);
278+
if err == nil {
279+
cname = rname;
280+
return;
281+
}
271282
return;
272283
}

src/pkg/net/net_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var dialErrorTests = []DialErrorTest{
3535
},
3636
DialErrorTest{
3737
"tcp", "", "no-such-name:80",
38-
`dial tcp no-such-name:80: lookup no-such-name\..*\.( on .*)?: no (.*)`,
38+
`dial tcp no-such-name:80: lookup no-such-name\.(.*\.)?( on .*)?: no (.*)`,
3939
},
4040
DialErrorTest{
4141
"tcp", "", "mh/astro/r70:http",

0 commit comments

Comments
 (0)