diff options
author | Erik Dubbelboer <erik@dubbelboer.com> | 2019-09-07 10:13:56 +0200 |
---|---|---|
committer | Erik Dubbelboer <erik@dubbelboer.com> | 2019-09-07 10:13:56 +0200 |
commit | e5e21db0c30040eede8af4d11abc91be6f996063 (patch) | |
tree | 1fc27ea23af65ed9092084348b95c62e3284cf65 /fasthttpproxy | |
parent | Fix data race in fasthttputil.pipeConn (#645) (diff) | |
download | fasthttp-e5e21db0c30040eede8af4d11abc91be6f996063.tar.gz fasthttp-e5e21db0c30040eede8af4d11abc91be6f996063.tar.bz2 fasthttp-e5e21db0c30040eede8af4d11abc91be6f996063.zip |
Reuse the socks5 dialer
Fixes https://github.com/valyala/fasthttp/issues/644
Diffstat (limited to 'fasthttpproxy')
-rw-r--r-- | fasthttpproxy/socks5.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fasthttpproxy/socks5.go b/fasthttpproxy/socks5.go index 77d965d..c1675e1 100644 --- a/fasthttpproxy/socks5.go +++ b/fasthttpproxy/socks5.go @@ -15,8 +15,13 @@ import ( // Dial: fasthttpproxy.FasthttpSocksDialer("localhost:9050"), // } func FasthttpSocksDialer(proxyAddr string) fasthttp.DialFunc { + dialer, err := proxy.SOCKS5("tcp", proxyAddr, nil, proxy.Direct) + // It would be nice if we could return the error here. But we can't + // change our API so just keep returning it in the returned Dial function. + // Besides the implementation of proxy.SOCKS5() at the time of writing this + // will always return nil as error. + return func(addr string) (net.Conn, error) { - dialer, err := proxy.SOCKS5("tcp", proxyAddr, nil, proxy.Direct) if err != nil { return nil, err } |