doufu3718 2018-11-09 06:48
浏览 472

发出请求时如何利用ipv6地址块

Hello all: How would I configure http.transport to handle using different ipv6 addresses to issue http requests (makeshift proxies). What I've tried:

    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,
    },
}

This fails with with ipv6 addresses:

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.

I have two main questions. How can I:

  1. Find the range of available ipv6 addresses I can use
  2. Use them programmatically in golang to make http requests (again, mimicking a proxy)

I guess what i'm asking is: how can I replicate this: https://github.com/blechschmidt/freebind/blob/master/freebind.c in go.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

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