瀏覽代碼

go.net/proxy: fix IP address determination

net.IP represents either an IPv4 or IPv6 address. In case of
the address of IPv4 node, it uses IPv4-mapped IPv6 address
format by default.

R=agl, dave
CC=golang-dev
https://golang.org/cl/6782078
Mikio Hara 13 年之前
父節點
當前提交
3805a43191
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      proxy/socks5.go

+ 1 - 1
proxy/socks5.go

@@ -142,7 +142,7 @@ func (s *socks5) Dial(network, addr string) (net.Conn, error) {
 	buf = append(buf, socks5Version, socks5Connect, 0 /* reserved */)
 	buf = append(buf, socks5Version, socks5Connect, 0 /* reserved */)
 
 
 	if ip := net.ParseIP(host); ip != nil {
 	if ip := net.ParseIP(host); ip != nil {
-		if len(ip) == 4 {
+		if ip.To4() != nil {
 			buf = append(buf, socks5IP4)
 			buf = append(buf, socks5IP4)
 		} else {
 		} else {
 			buf = append(buf, socks5IP6)
 			buf = append(buf, socks5IP6)