summaryrefslogtreecommitdiff
path: root/libgo/go/net/dnsclient_unix.go
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-10-26 23:57:58 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-10-26 23:57:58 +0000
commitfa5d125b5cfa5c935e46d27a2cbcd71ae37687ac (patch)
tree19d182df05ead7ff8ba7ee00a7d57555e1383fdf /libgo/go/net/dnsclient_unix.go
parente3d46e67996cf20ca3a75fccbb5a0007bfa3f992 (diff)
downloadgcc-fa5d125b5cfa5c935e46d27a2cbcd71ae37687ac.tar.gz
Update Go library to last weekly.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180552 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/net/dnsclient_unix.go')
-rw-r--r--libgo/go/net/dnsclient_unix.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/libgo/go/net/dnsclient_unix.go b/libgo/go/net/dnsclient_unix.go
index f407b177830..eb7db5e2707 100644
--- a/libgo/go/net/dnsclient_unix.go
+++ b/libgo/go/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.
@@ -113,7 +115,7 @@ func convertRR_A(records []dnsRR) []IP {
func convertRR_AAAA(records []dnsRR) []IP {
addrs := make([]IP, len(records))
for i, rr := range records {
- a := make(IP, 16)
+ a := make(IP, IPv6len)
copy(a, rr.(*dnsRR_AAAA).AAAA[:])
addrs[i] = a
}
@@ -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