diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2012-04-03 10:55:16 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2012-04-03 10:55:16 -0700 |
commit | 6a14926b44504e88488e3715b5b84928d454fb49 (patch) | |
tree | 9cf5f80773922c62ebd9ba07388a1f27354dc516 /libgo/go/net/dnsclient.go | |
parent | aabd700dee5d71eb0a8180fb3626a23da9a88fdd (diff) | |
parent | 749dea2a0549c126a0e992a6dd8e9b5eb28e1cee (diff) | |
download | gcc-hjl/x32/java.tar.gz |
Merge remote-tracking branch 'origin/master' into hjl/x32/javahjl/x32/java
Diffstat (limited to 'libgo/go/net/dnsclient.go')
-rw-r--r-- | libgo/go/net/dnsclient.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/libgo/go/net/dnsclient.go b/libgo/go/net/dnsclient.go index f4ed8b87cc1..e69cb3188bc 100644 --- a/libgo/go/net/dnsclient.go +++ b/libgo/go/net/dnsclient.go @@ -5,8 +5,6 @@ package net import ( - "bytes" - "fmt" "math/rand" "sort" ) @@ -45,20 +43,22 @@ func reverseaddr(addr string) (arpa string, err error) { return "", &DNSError{Err: "unrecognized address", Name: addr} } if ip.To4() != nil { - return fmt.Sprintf("%d.%d.%d.%d.in-addr.arpa.", ip[15], ip[14], ip[13], ip[12]), nil + return itoa(int(ip[15])) + "." + itoa(int(ip[14])) + "." + itoa(int(ip[13])) + "." + + itoa(int(ip[12])) + ".in-addr.arpa.", nil } // Must be IPv6 - var buf bytes.Buffer + buf := make([]byte, 0, len(ip)*4+len("ip6.arpa.")) // Add it, in reverse, to the buffer for i := len(ip) - 1; i >= 0; i-- { - s := fmt.Sprintf("%02x", ip[i]) - buf.WriteByte(s[1]) - buf.WriteByte('.') - buf.WriteByte(s[0]) - buf.WriteByte('.') + v := ip[i] + buf = append(buf, hexDigit[v&0xF]) + buf = append(buf, '.') + buf = append(buf, hexDigit[v>>4]) + buf = append(buf, '.') } // Append "ip6.arpa." and return (buf already has the final .) - return buf.String() + "ip6.arpa.", nil + buf = append(buf, "ip6.arpa."...) + return string(buf), nil } // Find answer for name in dns message. |