Establishing TCP Connections via Tor using Golang

I’ve tried using another goroutine but the program blocks whenever trying to retrieve data from the server.
server client
Basically whenever the client tries to read from the connection it gets stuck.


I create a dialer via

dialer := &net.Dialer{}

and a TLS dialer via

tlsDialer := &tls.Dialer{
    NetDialer: dialer,
    Config:    &tls.Config{InsecureSkipVerify: true},

Then, I develop a dialer for a socks5 proxy.

proxyDialer, err := proxy.SOCKS5("tcp", "", nil, proxy.Direct)

Is it possible to establish a connection with a remote server using a SOCKS5 proxy? Additionally, can the order of three dialers be arranged, with


being the first and

proxyDialer.Dial("tcp", "remote:port")

being the final step in connecting to the server?

My Env:

  • OS: Windows 10 x64
  • Golang: 1.16 (no CGO)

I would highly appreciate any assistance 🙂
I am a first-time questioner on SOF, kindly inform me if I missed any important details.


Thanks for @Steffen Ullrich

To establish a connection, a Dialer is employed. However, only a single
single connection
is available to
establish. Create
the connection through proxyDialer. In such cases, the connection given by proxyDialer is utilized to perform a tls.Client operation, which upgrades it to a tls.Conn.

Simply enhance the proxy connection by implementing TLS.

proxyDialer, err := proxy.SOCKS5("tcp", "proxyserver:1080", nil, proxy.Direct)
conn, err = proxyDialer.Dial("tcp", "server:port")
conn = tls.Client(conn, &tls.Config{InsecureSkipVerify: true})

Frequently Asked Questions

Posted in Ssl