Skip to content

Commit

Permalink
Reuse the socks5 dialer
Browse files Browse the repository at this point in the history
Fixes #644
  • Loading branch information
erikdubbelboer committed Sep 7, 2019
1 parent 8713335 commit e5e21db
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fasthttpproxy/socks5.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e5e21db

Please sign in to comment.