|
@@ -2,6 +2,7 @@ package proxyClient
|
|
|
|
|
|
import (
|
|
|
"bp.jydev.jianyu360.cn/BaseService/gateway/core/util"
|
|
|
+ "context"
|
|
|
"github.com/gogf/gf/v2/os/gcfg"
|
|
|
"github.com/gogf/gf/v2/os/gctx"
|
|
|
"net"
|
|
@@ -28,11 +29,13 @@ func CreateCustomProxyClient(target *url.URL, errFunc func(http.ResponseWriter,
|
|
|
func ReLoadClient() {
|
|
|
transport = &http.Transport{
|
|
|
Proxy: http.ProxyFromEnvironment,
|
|
|
- DialContext: (&net.Dialer{
|
|
|
- Timeout: time.Duration(gcfg.Instance().MustGet(gctx.New(), "proxy.timeout", 30).Int()) * time.Second, //连接超时
|
|
|
- KeepAlive: time.Duration(gcfg.Instance().MustGet(gctx.New(), "proxy.keepAlive", 60).Int()) * time.Second, //长连接超时时间
|
|
|
- DualStack: true,
|
|
|
- }).DialContext,
|
|
|
+ DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
|
|
+ dialer := &net.Dialer{
|
|
|
+ Timeout: time.Duration(gcfg.Instance().MustGet(gctx.New(), "proxy.timeout", 30).Int()) * time.Second, //连接超时
|
|
|
+ KeepAlive: time.Duration(gcfg.Instance().MustGet(gctx.New(), "proxy.keepAlive", 60).Int()) * time.Second, //长连接超时时间
|
|
|
+ }
|
|
|
+ return dialer.DialContext(ctx, network, addr)
|
|
|
+ },
|
|
|
MaxIdleConns: gcfg.Instance().MustGet(gctx.New(), "proxy.maxIdleConns", 120).Int(), //最大空闲连接 0没有限制
|
|
|
IdleConnTimeout: time.Duration(gcfg.Instance().MustGet(gctx.New(), "proxy.idleConnTimeout", 90).Int()) * time.Second, //空闲超时时间
|
|
|
TLSHandshakeTimeout: time.Duration(gcfg.Instance().MustGet(gctx.New(), "proxy.tLSHandshakeTimeout", 1).Int()) * time.Second, //tls握手超时时间
|