mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
40bdc4abc7
* feat(fasthttpproxy): add dual-stack connection support to enable IPv6 proxies for HTTP and SOCKS5 dialers - Added `FasthttpHTTPDialerDualStack` to support dual-stack (IPv4 and IPv6) connections for HTTP proxies, enabling IPv6 proxy usage. - Added `FasthttpSocksDialerDualStack` to support dual-stack (IPv4 and IPv6) connections for SOCKS5 proxies, enabling IPv6 proxy usage. - Improved dialer configuration to ensure compatibility with both IPv4 and IPv6 proxies. * fix(lint): address linting issues in code
35 lines
1.0 KiB
Go
35 lines
1.0 KiB
Go
package fasthttpproxy
|
|
|
|
import (
|
|
"github.com/valyala/fasthttp"
|
|
"golang.org/x/net/http/httpproxy"
|
|
)
|
|
|
|
// FasthttpSocksDialer returns a fasthttp.DialFunc that dials using
|
|
// the provided SOCKS5 proxy.
|
|
//
|
|
// Example usage:
|
|
//
|
|
// c := &fasthttp.Client{
|
|
// Dial: fasthttpproxy.FasthttpSocksDialer("socks5://localhost:9050"),
|
|
// }
|
|
func FasthttpSocksDialer(proxyAddr string) fasthttp.DialFunc {
|
|
d := Dialer{Config: httpproxy.Config{HTTPProxy: proxyAddr, HTTPSProxy: proxyAddr}}
|
|
dialFunc, _ := d.GetDialFunc(false)
|
|
return dialFunc
|
|
}
|
|
|
|
// FasthttpSocksDialerDualStack returns a fasthttp.DialFunc that dials using
|
|
// the provided SOCKS5 proxy with support for both IPv4 and IPv6.
|
|
//
|
|
// Example usage:
|
|
//
|
|
// c := &fasthttp.Client{
|
|
// Dial: fasthttpproxy.FasthttpSocksDialerDualStack("socks5://localhost:9050"),
|
|
// }
|
|
func FasthttpSocksDialerDualStack(proxyAddr string) fasthttp.DialFunc {
|
|
d := Dialer{Config: httpproxy.Config{HTTPProxy: proxyAddr, HTTPSProxy: proxyAddr}, DialDualStack: true}
|
|
dialFunc, _ := d.GetDialFunc(false)
|
|
return dialFunc
|
|
}
|