]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix dns bug reported on irc.
authorRuss Cox <rsc@golang.org>
Wed, 11 Nov 2009 01:09:33 +0000 (17:09 -0800)
committerRuss Cox <rsc@golang.org>
Wed, 11 Nov 2009 01:09:33 +0000 (17:09 -0800)
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

src/pkg/net/dnsclient.go
src/pkg/net/net_test.go

index bea31c3ceb132d8cea985a04fbc5fd645925fca2..064e1017bf98b3a13e5107cf2bccdc2520651e0a 100644 (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;
 }
index 532a62b985ca0b8fdf84fd1d3ada3c76115ad4f9..c06a05b3efcac1e07b70b00b1bcfbaaa450df0fe 100644 (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",