我想用socks5连接到smtp
//its work
...
host := "mx.yandex.ru"
c, err := smtp.Dial(host + ":2525")
...
//its not work
...
import "golang.org/x/net/proxy"
...
dialer, _:= proxy.SOCKS5("tcp", p, nil, proxy.Direct)
_, err = dialer.Dial("tcp", "mx.yandex.ru:2525")
if err != nil {
fmt.Printf("ERROR %v\n", err)
os.Exit(1)
}
错误袜子连接tcp x.x.x.x:y-> mx.yandex.ru:2525:未知错误网络无法访问
但是这个可行。为什么?
dialer, _:= proxy.SOCKS5("tcp", p, nil, proxy.Direct)
_, err = dialer.Dial("tcp", "yandex.ru:80")
if err != nil {
fmt.Printf("ERROR %v\n", err)
os.Exit(1)
}