Skip to content
Permalink
Browse files

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
  • Loading branch information...
rsc committed Nov 11, 2009
1 parent c8bb81f commit 484f46daea9a44afd9fc0ea90b2172dfa524d9bb
Showing with 12 additions and 1 deletion.
  1. +11 −0 src/pkg/net/dnsclient.go
  2. +1 −1 src/pkg/net/net_test.go
@@ -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;
}
@@ -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",

0 comments on commit 484f46d

Please sign in to comment.
You can’t perform that action at this time.