From 842e70e477e5c0b226067afed36eb699732d59ca Mon Sep 17 00:00:00 2001 From: suiahae <45323123+suiahae@users.noreply.github.com> Date: Sat, 28 Jan 2023 21:09:23 +0800 Subject: [PATCH] add max_delay_time parameter to frpc --- client/service.go | 2 +- pkg/config/client.go | 3 +++ pkg/config/client_test.go | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/client/service.go b/client/service.go index b72fea77..336b536d 100644 --- a/client/service.go +++ b/client/service.go @@ -168,7 +168,7 @@ func (svr *Service) Run() error { func (svr *Service) keepControllerWorking() { xl := xlog.FromContextSafe(svr.ctx) - maxDelayTime := 20 * time.Second + maxDelayTime := time.Duration(svr.cfg.MaxDelayTime) * time.Second delayTime := time.Second // if frpc reconnect frps, we need to limit retry times in 1min diff --git a/pkg/config/client.go b/pkg/config/client.go index 906ee985..3ea98575 100644 --- a/pkg/config/client.go +++ b/pkg/config/client.go @@ -161,6 +161,8 @@ type ClientCommonConf struct { // Enable golang pprof handlers in admin listener. // Admin port must be set first. PprofEnable bool `ini:"pprof_enable" json:"pprof_enable"` + // MaxDelayTime specifies the maximum waiting time for frpc to reconnect frps. + MaxDelayTime int64 `ini:"max_delay_time" json:"max_delay_time"` } // GetDefaultClientConf returns a client configuration with default values. @@ -191,6 +193,7 @@ func GetDefaultClientConf() ClientCommonConf { Metas: make(map[string]string), UDPPacketSize: 1500, IncludeConfigFiles: make([]string, 0), + MaxDelayTime: 20, } } diff --git a/pkg/config/client_test.go b/pkg/config/client_test.go index 9cf8c805..55cfffdf 100644 --- a/pkg/config/client_test.go +++ b/pkg/config/client_test.go @@ -296,6 +296,7 @@ func Test_LoadClientCommonConf(t *testing.T) { }, UDPPacketSize: 1509, IncludeConfigFiles: []string{}, + MaxDelayTime: 60, } common, err := UnmarshalClientConfFromIni(testClientBytesWithFull)