doudou3716 2014-08-06 03:24 采纳率: 100%
浏览 75
已采纳

如何通过袜子连接到imap? 走

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
}
  • 写回答

1条回答 默认 最新

  • donglao7947 2014-08-06 18:53
    关注

    forward is the Dialer used to connect to the proxy.

    You can use proxy.Direct here if you want (which is the default within the package, if you look at the source), but all that is doing is delegating to net.Dial(network, addr). If you want more options, insert your own Dialer.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料