如何创建一个net.Conn连接到一个带有用户/密码身份验证的Socks 5服务器
conn,err:=net.Dial("tcp","user:pass@ip_addr:port")
5uzkadbs1#
d, err := proxy.SOCKS5("tcp", surl.Host, auth, forwrder) if err != nil { return nil, err } conn, err := d.Dial("tcp", testURL) if err != nil { return nil, err } defer conn.Close()
u3r8eeie2#
import ( "net" "time" "golang.org/x/net/proxy" ) auth := proxy.Auth{User: "username", Password: "password"} dailer, err := proxy.SOCKS5("tcp", "socks5_ip:port", &auth, &net.Dialer{ Timeout: 60 * time.Second, KeepAlive: 30 * time.Second, }) conn, err := dailer.Dial("tcp", "target_ip:port")
2条答案
按热度按时间5uzkadbs1#
u3r8eeie2#