From 77990c31ef625261fefe0e926d08cca509fa78dc Mon Sep 17 00:00:00 2001 From: fatedier Date: Thu, 30 May 2024 10:36:30 +0800 Subject: [PATCH] fix ini configuration default values (#4250) --- Release.md | 1 + pkg/config/legacy/client.go | 24 ++++------------------- pkg/config/legacy/server.go | 38 ++++++++++++------------------------- 3 files changed, 17 insertions(+), 46 deletions(-) diff --git a/Release.md b/Release.md index 5cb27c3..a1fa993 100644 --- a/Release.md +++ b/Release.md @@ -1,6 +1,7 @@ ### Fixes * Fixed an issue where HTTP/2 was not enabled for https2http and https2https plugins. +* Fixed the issue where the default values of INI configuration parameters are inconsistent with other configuration formats. ### Changes diff --git a/pkg/config/legacy/client.go b/pkg/config/legacy/client.go index b45ed06..7c16c73 100644 --- a/pkg/config/legacy/client.go +++ b/pkg/config/legacy/client.go @@ -345,35 +345,19 @@ func copySection(source, target *ini.Section) { } // GetDefaultClientConf returns a client configuration with default values. +// Note: Some default values here will be set to empty and will be converted to them +// new configuration through the 'Complete' function to set them as the default +// values of the new configuration. func GetDefaultClientConf() ClientCommonConf { return ClientCommonConf{ ClientConfig: legacyauth.GetDefaultClientConf(), - ServerAddr: "0.0.0.0", - ServerPort: 7000, - NatHoleSTUNServer: "stun.easyvoip.com:3478", - DialServerTimeout: 10, - DialServerKeepAlive: 7200, - HTTPProxy: os.Getenv("http_proxy"), - LogFile: "console", - LogWay: "console", - LogLevel: "info", - LogMaxDays: 3, - AdminAddr: "127.0.0.1", - PoolCount: 1, TCPMux: true, - TCPMuxKeepaliveInterval: 60, LoginFailExit: true, - Start: make([]string, 0), Protocol: "tcp", - QUICKeepalivePeriod: 10, - QUICMaxIdleTimeout: 30, - QUICMaxIncomingStreams: 100000, + Start: make([]string, 0), TLSEnable: true, DisableCustomTLSFirstByte: true, - HeartbeatInterval: 30, - HeartbeatTimeout: 90, Metas: make(map[string]string), - UDPPacketSize: 1500, IncludeConfigFiles: make([]string, 0), } } diff --git a/pkg/config/legacy/server.go b/pkg/config/legacy/server.go index 1279a49..c58f76a 100644 --- a/pkg/config/legacy/server.go +++ b/pkg/config/legacy/server.go @@ -200,34 +200,20 @@ type ServerCommonConf struct { NatHoleAnalysisDataReserveHours int64 `ini:"nat_hole_analysis_data_reserve_hours" json:"nat_hole_analysis_data_reserve_hours"` } -// GetDefaultServerConf returns a server configuration with reasonable -// defaults. +// GetDefaultServerConf returns a server configuration with reasonable defaults. +// Note: Some default values here will be set to empty and will be converted to them +// new configuration through the 'Complete' function to set them as the default +// values of the new configuration. func GetDefaultServerConf() ServerCommonConf { return ServerCommonConf{ - ServerConfig: legacyauth.GetDefaultServerConf(), - BindAddr: "0.0.0.0", - BindPort: 7000, - QUICKeepalivePeriod: 10, - QUICMaxIdleTimeout: 30, - QUICMaxIncomingStreams: 100000, - VhostHTTPTimeout: 60, - DashboardAddr: "0.0.0.0", - LogFile: "console", - LogWay: "console", - LogLevel: "info", - LogMaxDays: 3, - DetailedErrorsToClient: true, - TCPMux: true, - TCPMuxKeepaliveInterval: 60, - TCPKeepAlive: 7200, - AllowPorts: make(map[int]struct{}), - MaxPoolCount: 5, - MaxPortsPerClient: 0, - HeartbeatTimeout: 90, - UserConnTimeout: 10, - HTTPPlugins: make(map[string]HTTPPluginOptions), - UDPPacketSize: 1500, - NatHoleAnalysisDataReserveHours: 7 * 24, + ServerConfig: legacyauth.GetDefaultServerConf(), + DashboardAddr: "0.0.0.0", + LogFile: "console", + LogWay: "console", + DetailedErrorsToClient: true, + TCPMux: true, + AllowPorts: make(map[int]struct{}), + HTTPPlugins: make(map[string]HTTPPluginOptions), } }