diff options
| author | Ondřej Surý <ondrej@sury.org> | 2011-10-06 09:35:45 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2011-10-06 09:35:45 +0200 |
| commit | 6c7ca6e4d4e26e4c8cbe0d183966011b3b088a0a (patch) | |
| tree | fddeb87db026d64a1d8e597dd0c69d685f433597 /src/pkg/net/dnsclient_unix.go | |
| parent | 04f99b387021a8ce32a8795360cba9beaf986a81 (diff) | |
| download | golang-6c7ca6e4d4e26e4c8cbe0d183966011b3b088a0a.tar.gz | |
Imported Upstream version 2011.09.21upstream-weekly/2011.09.21
Diffstat (limited to 'src/pkg/net/dnsclient_unix.go')
| -rw-r--r-- | src/pkg/net/dnsclient_unix.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/pkg/net/dnsclient_unix.go b/src/pkg/net/dnsclient_unix.go index cb4645509..eb7db5e27 100644 --- a/src/pkg/net/dnsclient_unix.go +++ b/src/pkg/net/dnsclient_unix.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build darwin freebsd linux openbsd + // DNS client: see RFC 1035. // Has to be linked into package net for Dial. @@ -213,6 +215,18 @@ func goLookupHost(name string) (addrs []string, err os.Error) { // depending on our lookup code, so that Go and C get the same // answers. func goLookupIP(name string) (addrs []IP, err os.Error) { + // Use entries from /etc/hosts if possible. + haddrs := lookupStaticHost(name) + if len(haddrs) > 0 { + for _, haddr := range haddrs { + if ip := ParseIP(haddr); ip != nil { + addrs = append(addrs, ip) + } + } + if len(addrs) > 0 { + return + } + } onceLoadConfig.Do(loadConfig) if dnserr != nil || cfg == nil { err = dnserr |
