aboutsummaryrefslogtreecommitdiff
path: root/fasthttpproxy
diff options
context:
space:
mode:
authorGravatar Pluto <68190554+Pluto-zZ-zZ@users.noreply.github.com> 2023-07-21 15:55:22 +0800
committerGravatar GitHub <noreply@github.com> 2023-07-21 09:55:22 +0200
commite181af17c77ac3f2041a192bc59a86210a00e09e (patch)
tree69505d8e3eee14abf72b972762f7019f812d55f5 /fasthttpproxy
parentfix:fasthttp server with tlsConfig (#1595) (diff)
downloadfasthttp-e181af17c77ac3f2041a192bc59a86210a00e09e.tar.gz
fasthttp-e181af17c77ac3f2041a192bc59a86210a00e09e.tar.bz2
fasthttp-e181af17c77ac3f2041a192bc59a86210a00e09e.zip
fasthttpproxy support ipv6 (#1597)
Co-authored-by: liwengang <liwengang.zz@bytedance.com>
Diffstat (limited to 'fasthttpproxy')
-rw-r--r--fasthttpproxy/http.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/fasthttpproxy/http.go b/fasthttpproxy/http.go
index 94d2b09..c09bb2c 100644
--- a/fasthttpproxy/http.go
+++ b/fasthttpproxy/http.go
@@ -42,11 +42,23 @@ func FasthttpHTTPDialerTimeout(proxy string, timeout time.Duration) fasthttp.Dia
return func(addr string) (net.Conn, error) {
var conn net.Conn
var err error
- if timeout == 0 {
- conn, err = fasthttp.Dial(proxy)
+
+ if strings.HasPrefix(proxy, "[") {
+ // ipv6
+ if timeout == 0 {
+ conn, err = fasthttp.DialDualStack(proxy)
+ } else {
+ conn, err = fasthttp.DialDualStackTimeout(proxy, timeout)
+ }
} else {
- conn, err = fasthttp.DialTimeout(proxy, timeout)
+ // ipv4
+ if timeout == 0 {
+ conn, err = fasthttp.Dial(proxy)
+ } else {
+ conn, err = fasthttp.DialTimeout(proxy, timeout)
+ }
}
+
if err != nil {
return nil, err
}