'Golang tcp-tls over socks5 proxy client

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 create a socks5 proxy dialer by using

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

How can I connect remote server though the socks5 proxy?
In other way, how to nest three dialer in the order of net.Dialer->tls.Dialer->proxy.Dialer and finally using proxyDialer.Dial("tcp", "remote:port") to connect the server?

My Env:

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

Any help would be greatly appreciated :) First time asking question in SOF, if I missed sth to say pls tell me :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source