MCPcopy Create free account
hub / github.com/V2RaySSR/RealityChecker / mergeConfig

Function mergeConfig

internal/config/config.go:72–129  ·  view source on GitHub ↗

mergeConfig 合并配置

(defaultConfig *types.Config, fileConfig *types.Config)

Source from the content-addressed store, hash-verified

70
71// mergeConfig 合并配置
72func mergeConfig(defaultConfig *types.Config, fileConfig *types.Config) {
73 // 网络配置
74 if fileConfig.Network.Timeout > 0 {
75 defaultConfig.Network.Timeout = fileConfig.Network.Timeout
76 }
77 if fileConfig.Network.Retries >= 0 {
78 defaultConfig.Network.Retries = fileConfig.Network.Retries
79 }
80 if len(fileConfig.Network.DNSServers) > 0 {
81 defaultConfig.Network.DNSServers = fileConfig.Network.DNSServers
82 }
83
84 // TLS配置
85 if fileConfig.TLS.MinVersion > 0 {
86 defaultConfig.TLS.MinVersion = fileConfig.TLS.MinVersion
87 }
88 if fileConfig.TLS.MaxVersion > 0 {
89 defaultConfig.TLS.MaxVersion = fileConfig.TLS.MaxVersion
90 }
91
92 // 并发配置
93 if fileConfig.Concurrency.MaxConcurrent > 0 {
94 defaultConfig.Concurrency.MaxConcurrent = fileConfig.Concurrency.MaxConcurrent
95 }
96 if fileConfig.Concurrency.CheckTimeout > 0 {
97 defaultConfig.Concurrency.CheckTimeout = fileConfig.Concurrency.CheckTimeout
98 }
99 if fileConfig.Concurrency.CacheTTL > 0 {
100 defaultConfig.Concurrency.CacheTTL = fileConfig.Concurrency.CacheTTL
101 }
102
103 // 输出配置
104 if fileConfig.Output.Format != "" {
105 defaultConfig.Output.Format = fileConfig.Output.Format
106 }
107 defaultConfig.Output.Color = fileConfig.Output.Color
108 defaultConfig.Output.Verbose = fileConfig.Output.Verbose
109
110 // 缓存配置
111 defaultConfig.Cache.DNSEnabled = fileConfig.Cache.DNSEnabled
112 defaultConfig.Cache.ResultEnabled = fileConfig.Cache.ResultEnabled
113 if fileConfig.Cache.TTL > 0 {
114 defaultConfig.Cache.TTL = fileConfig.Cache.TTL
115 }
116 if fileConfig.Cache.MaxSize > 0 {
117 defaultConfig.Cache.MaxSize = fileConfig.Cache.MaxSize
118 }
119
120 // 批量配置
121 defaultConfig.Batch.StreamOutput = fileConfig.Batch.StreamOutput
122 defaultConfig.Batch.ProgressBar = fileConfig.Batch.ProgressBar
123 if fileConfig.Batch.ReportFormat != "" {
124 defaultConfig.Batch.ReportFormat = fileConfig.Batch.ReportFormat
125 }
126 if fileConfig.Batch.Timeout > 0 {
127 defaultConfig.Batch.Timeout = fileConfig.Batch.Timeout
128 }
129}

Callers 1

loadConfigFromFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected