douxiangbiao1899 2018-05-08 08:15
浏览 228

使用golang 1.10.2使用IKEv2证书连接到socks5代理

I use Go 1.10.2 for my client application.

I'm trying to connect to a socks5 proxy that requires username, password and IKEv2 certificate file.

this is what I've got so far:

 func socks5(proxyAdress string, url string, user string, password string) {
        auth := proxy.Auth{User: user, Password: password}
        if proxy, err := proxy.SOCKS5("tcp", proxyAdress, &auth, proxy.Direct);  err != nil {
            log.Fatalf("error: %v", proxy)
        } else {
            tr := &http.Transport{Dial: proxy.Dial}

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

            if resp, err2 := myClient.Get(url); err2 != nil {
                log.Fatalf("error: %v", err2)
            } else {
                if bodyBytes, err3 := ioutil.ReadAll(resp.Body); err3 != nil {
                    log.Fatalf("error: %v", err3)
                } else {
                    str := string(bodyBytes)
                    log.Printf(str)
                }

            }
        }
    }

when I execute this function with the proper parameters

I get an error from the server that I don't have permissions to access the web page I requested. that's because I didn't specify the IKEv2 key file.

so.. first.. how do I do that ?

and 2nd... Dial is deprecated.. I'm supposed to use DialContext but has no idea how

thanks ! :)

update

the OS that I use is MacOS High Sierra 10.13.4

the problem is that for example when I execute

socks5("il7.nordvpn.com:1080", "http://ifconfig.me/ip","MY_USER","MY_PASS")

the error that I get is

2018/05/15 23:34:49 error: Get http://ifconfig.me/ip: socks connect tcp ifconfig.me:80->ifconfig.me:80: EOF

I don't know where to provide the IKEv2 certificate

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮