From 1d4af2d92bcae7ec394830e58435ded6454882ef Mon Sep 17 00:00:00 2001 From: Larvan2 <78135608+Larvan2@users.noreply.github.com> Date: Sun, 3 Sep 2023 20:42:54 +0800 Subject: [PATCH] chore: TCPKeepAlive interval set to 15s by default --- common/net/tcpip.go | 2 +- config/config.go | 8 ++++---- docs/config.yaml | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/common/net/tcpip.go b/common/net/tcpip.go index 171191e2..7bc31edd 100644 --- a/common/net/tcpip.go +++ b/common/net/tcpip.go @@ -7,7 +7,7 @@ import ( "time" ) -var KeepAliveInterval time.Duration +var KeepAliveInterval = 15 * time.Second func SplitNetworkType(s string) (string, string, error) { var ( diff --git a/config/config.go b/config/config.go index cb030530..4421adc2 100644 --- a/config/config.go +++ b/config/config.go @@ -571,11 +571,11 @@ func parseGeneral(cfg *RawConfig) (*General, error) { C.GeoSiteUrl = cfg.GeoXUrl.GeoSite C.MmdbUrl = cfg.GeoXUrl.Mmdb C.GeodataMode = cfg.GeodataMode - if cfg.KeepAliveInterval == 0 { - cfg.KeepAliveInterval = 30 + if cfg.KeepAliveInterval != 0 { + N.KeepAliveInterval = time.Duration(cfg.KeepAliveInterval) * time.Second } - N.KeepAliveInterval = time.Duration(cfg.KeepAliveInterval) * time.Second - log.Infoln("Keep Alive Interval set %+v", N.KeepAliveInterval) + + log.Debugln("TCP Keep Alive Interval set %+v", N.KeepAliveInterval) // checkout externalUI exist if externalUI != "" { externalUI = C.Path.Resolve(externalUI) diff --git a/docs/config.yaml b/docs/config.yaml index ca33911e..cd540311 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -50,7 +50,8 @@ external-ui: /path/to/ui/folder # 配置 WEB UI 目录,使用 http://{{externa # Utls is currently support TLS transport in TCP/grpc/WS/HTTP for VLESS/Vmess and trojan. global-client-fingerprint: chrome -keep-alive-interval: 30 +# TCP keep alive interval +keep-alive-interval: 15 # routing-mark:6666 # 配置 fwmark 仅用于 Linux experimental: