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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何用stata画出文献中常见的安慰剂检验图
    • ¥15 c语言链表结构体数据插入
    • ¥40 使用MATLAB解答线性代数问题
    • ¥15 COCOS的问题COCOS的问题
    • ¥15 FPGA-SRIO初始化失败
    • ¥15 MapReduce实现倒排索引失败
    • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
    • ¥15 找一位技术过硬的游戏pj程序员
    • ¥15 matlab生成电测深三层曲线模型代码
    • ¥50 随机森林与房贷信用风险模型