Skip to content

Commit

Permalink
net: fix dns bug reported on irc.
Browse files Browse the repository at this point in the history
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 484f46d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/pkg/net/dnsclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/pkg/net/net_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 484f46d

Please sign in to comment.