创建一个go socks5客户端 [英] Creating a go socks5 client

查看:127
本文介绍了创建一个go socks5客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在查看net/proxy文档,并且完全没有有关如何使用其任何方法的示例.我正在研究使用socks5.该函数的外观如下:

So I'm looking at the net/proxy docs and there is no examples at all of how to use any of its methods. I'm looking into using socks5. This is the how the function looks:

func SOCKS5(network, addr string, auth *Auth, forward Dialer) (Dialer, error)

现在一切都说得通了,除了我对forward(它是Dialer类型)感到困惑,并且函数本身返回了Dialer.其他一切都有意义,network, add, auth只是把我赶走了.我如何设置我的客户端以使用socks5 Dialer?

Now everything kinda makes sense except I'm confused about forward which is a type Dialer and the function itself returns a Dialer. Everything else makes sense network, add, auth just forward is throwing me off. How would I set my client up to use the socks5 Dialer?

推荐答案

所以我能够找到我的问题的答案,任何有兴趣在此处设置socks5客户的人都是这样的:

So I was able to find the answer to my question anyone interested how to set up a socks5 client in go here it is:

dialSocksProxy, err := proxy.SOCKS5("tcp", "proxy_ip", nil, proxy.Direct)
if err != nil {
    fmt.Println("Error connecting to proxy:", err)
}
tr := &http.Transport{Dial: dialSocksProxy.Dial}

// Create client
myClient := &http.Client{
    Transport: tr,
}

这篇关于创建一个go socks5客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆