1
0
mirror of https://github.com/golang/go synced 2024-11-12 09:30:25 -07:00

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
This commit is contained in:
Russ Cox 2009-11-10 17:09:33 -08:00
parent c8bb81fddc
commit 484f46daea
2 changed files with 12 additions and 1 deletions

View File

@ -268,5 +268,16 @@ func LookupHost(name string) (cname string, addrs []string, err os.Error) {
return;
}
}
// Last ditch effort: try unsuffixed.
rname := name;
if !rooted {
rname += "."
}
addrs, err = tryOneName(cfg, rname);
if err == nil {
cname = rname;
return;
}
return;
}

View File

@ -35,7 +35,7 @@ var dialErrorTests = []DialErrorTest{
},
DialErrorTest{
"tcp", "", "no-such-name:80",
`dial tcp no-such-name:80: lookup no-such-name\..*\.( on .*)?: no (.*)`,
`dial tcp no-such-name:80: lookup no-such-name\.(.*\.)?( on .*)?: no (.*)`,
},
DialErrorTest{
"tcp", "", "mh/astro/r70:http",