mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-16 16:17:38 +03:00
committed by
Kirill Danshin
parent
d7688109a5
commit
7529e6b2e5
@@ -0,0 +1,25 @@
|
||||
package fasthttpproxy
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/valyala/fasthttp"
|
||||
"golang.org/x/net/proxy"
|
||||
)
|
||||
|
||||
// FasthttpSocksDialer returns a fasthttp.DialFunc that dials using
|
||||
// the provided SOCKS5 proxy.
|
||||
//
|
||||
// Example usage:
|
||||
// c := &fasthttp.Client{
|
||||
// Dial: fasthttpproxy.FasthttpSocksDialer("localhost:9050"),
|
||||
// }
|
||||
func FasthttpSocksDialer(proxyAddr string) fasthttp.DialFunc {
|
||||
return func(addr string) (net.Conn, error) {
|
||||
dialer, err := proxy.SOCKS5("tcp", proxyAddr, nil, proxy.Direct)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dialer.Dial("tcp", addr)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user