mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
fasthttpproxy support ipv6 (#1597)
Co-authored-by: liwengang <liwengang.zz@bytedance.com>
This commit is contained in:
+15
-3
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user