func (s *socks5) Dial(network, addr string) (net.Conn, error) {
	switch network {
	case "tcp", "tcp6", "tcp4":
	default:
		return nil, errors.New("proxy: no support for SOCKS5 proxy connections of type " + network)
	}
	conn, err := s.forward.Dial(s.network, s.addr)
	if err != nil {
		return nil, err
	}
	if err := s.connect(conn, addr); err != nil {
		conn.Close()
		return nil, err
	}
	return conn, nil
}
Dial connects to the address addr on the network net via the SOCKS5 proxy.
package proxy
import (
	"errors"
	"io"
	"net"
	"strconv"
)
func SOCKS5(network, addr string, auth *Auth, forward Dialer) (Dialer, error) {
	s := &socks5{
		network: network,
		addr:    addr,
		forward: forward,
	}
	if auth != nil {
		s.user = auth.User
		s.password = auth.Password
	}
	return s, nil
}
type socks5 struct {
	user, password string
	network, addr  string
	forward        Dialer
}
const socks5Version = 5
const (
	socks5AuthNone     = 0
	socks5AuthPassword = 2
)
const socks5Connect = 1
const (
	socks5IP4    = 1
	socks5Domain = 3
	socks5IP6    = 4
)
var socks5Errors = []string{
	"",
	"general failure",
	"connection forbidden",
	"network unreachable",
	"host unreachable",
	"connection refused",
	"TTL expired",
	"command not supported",
	"address type not supported",
}