gpt4 book ai didi

go - 如何在http客户端上使用Socks4

转载 作者:行者123 更新时间:2023-12-01 21:10:35 25 4
gpt4 key购买 nike

这是我目前使用Socks5的解决方案。有什么解决方案可以使Socks4正常工作吗?我想发送一个带有Socks4的Get请求。

proxyUrl, err := url.Parse("socks5://123.123.123.123:9999")
myClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyUrl)}}

最佳答案

net/http/transport仅支持现成的httphttpssocks5代理(引用文档):

The proxy type is determined by the URL scheme. "http", "https", and "socks5" are supported. If the scheme is empty, "http" is assumed.



要使用 socks4socks4a代理,您可以使用现有的库,例如 h12.io/socks,然后将 socks4拨盘传递给 Transport,如下所示:

import "h12.io/socks"

dial := socks.Dial("socks4://123.123.123.123:9999")
transp := &http.Transport{Dial: dial}
myClient := &http.Client{Transport: transp}

关于go - 如何在http客户端上使用Socks4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61534124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com