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