Go http client怎么使用shadowsocks代理?

google了好久只有http代理的。

proxy := func(_ *http.Request) (*url.URL, error) {
        return url.Parse("http://127.0.0.1:1087")
        //return url.Parse("ss://rc4-md5:123456@ss.server.com:1080")
    }
http.Client.Transport = &http.Transport{Proxy: proxy}

这种,怎么才能使用ss代理?

共 4 个回复


fanyang

看看源码说不定你能找到答案
github.com/shadowsocks/shadowsocks-go

# 1

tiny1990

    dialSocksProxy, err := proxy.SOCKS5("tcp", "127.0.0.1:1086", nil, proxy.Direct)
    if err != nil {
        fmt.Println("Error connecting to proxy:", err)
    }
    tr := &http.Transport{Dial: dialSocksProxy.Dial}

    // Create client
    myClient := &http.Client{
        Transport: tr,
    }
    response, _ := myClient.Get("http://1212.ip138.com/ic.asp")
    defer response.Body.Close()
    var by []byte
    by, _ = ioutil.ReadAll(response.Body)
    fmt.Println(string(by))

start a ss client in your machine ,use your ss-client port,

# 2

huff

ssr代理有用户名吗? 弱弱的问一句

# 3