大家好:我将如何配置http.transport以使用不同的ipv6地址来发出http请求(临时代理)。 我尝试过的:
localAddr, err := net.ResolveIPAddr("ip6", "{ipv6 address}")
if err != nil {
panic(err)
}
localTCPAddr := net.TCPAddr{
IP: localAddr.IP,
}
webclient := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
LocalAddr: &localTCPAddr,
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
},
}
ipv6地址失败:
panic: Get https://myip.addr.space/: dial tcp [{localAddr}]:0->[{hostip?}]:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
我有两个主要问题。我该怎么办
我想我要问的是:我该如何复制:https://github.com/blechschmidt/freebind/blob/master/freebind.c。