Commit 484f46da authored by Russ Cox's avatar Russ Cox

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
parent c8bb81fd
...@@ -268,5 +268,16 @@ func LookupHost(name string) (cname string, addrs []string, err os.Error) { ...@@ -268,5 +268,16 @@ func LookupHost(name string) (cname string, addrs []string, err os.Error) {
return; return;
} }
} }
// Last ditch effort: try unsuffixed.
rname := name;
if !rooted {
rname += "."
}
addrs, err = tryOneName(cfg, rname);
if err == nil {
cname = rname;
return;
}
return; return;
} }
...@@ -35,7 +35,7 @@ var dialErrorTests = []DialErrorTest{ ...@@ -35,7 +35,7 @@ var dialErrorTests = []DialErrorTest{
}, },
DialErrorTest{ DialErrorTest{
"tcp", "", "no-such-name:80", "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{ DialErrorTest{
"tcp", "", "mh/astro/r70:http", "tcp", "", "mh/astro/r70:http",
......
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