I'm trying to connect to an IMAP server through a socks5. To do so I've exported some functions from the Imap package but I got stuck at the socks5 dialer setup(1st step:) .
I think the reason is that I'm passing nil
as forward
(of type Dial
) argument . What is the forward
argument supposed to be ? It is not documented (in godoc)
func dialSocks(socks string) (Dial proxy.Dialer, err error) {
Dial, err = proxy.SOCKS5("tcp", socks, nil, nil)
return
}
func dialTLS(addr string, config *tls.Config) (c *imap.Client, err error) {
addr = defaultPort(addr, "993")
d, err := dialSocks("101.120.113.185:1328")
if err != nil {
log.Error(err)
return
}
conn, err := d.Dial("tcp", addr)
if err == nil {
host, _, _ := net.SplitHostPort(addr)
tlsConn := tls.Client(conn, setServerName(config, host))
if c, err = imap.NewClient(tlsConn, host, 60*time.Second); err != nil {
conn.Close()
}
}
return
}
func defaultPort(addr, port string) string {
_, _, err := net.SplitHostPort(addr)
if err != nil {
addr = net.JoinHostPort(addr, port)
}
return addr
}