feat: 完善代理池与抢购链路,发布 0.5.0
This commit is contained in:
+19
-12
@@ -164,17 +164,18 @@ func envInt(key string, fallback int) int {
|
||||
// defaultConfig 返回内置默认配置。
|
||||
func defaultConfig() types.Config {
|
||||
return types.Config{
|
||||
Activity: activity.DefaultActivityID,
|
||||
TimeAPIURL: constants.DefaultTimeAPI,
|
||||
TraceEnabled: false,
|
||||
TraceMaxBody: 0,
|
||||
LogLevel: "info",
|
||||
Concurrency: constants.DefaultConcurrency,
|
||||
Attempts: constants.DefaultAttempts,
|
||||
RetryStages: defaultRetryStages(),
|
||||
SeckillMode: types.SeckillModeAggressive,
|
||||
XiaodianPageSize: 200,
|
||||
AccountsPerProxy: constants.DefaultAccountsPerProxy,
|
||||
Activity: activity.DefaultActivityID,
|
||||
TimeAPIURL: constants.DefaultTimeAPI,
|
||||
TraceEnabled: false,
|
||||
TraceMaxBody: 0,
|
||||
LogLevel: "info",
|
||||
Concurrency: constants.DefaultConcurrency,
|
||||
Attempts: constants.DefaultAttempts,
|
||||
RetryStages: defaultRetryStages(),
|
||||
SeckillMode: types.SeckillModeAggressive,
|
||||
XiaodianPageSize: 200,
|
||||
AccountsPerProxy: constants.DefaultAccountsPerProxy,
|
||||
ProxySparePercent: constants.DefaultProxySparePercent,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +215,7 @@ func LoadConfig(path string) types.Config {
|
||||
if cfg.Activity == "" {
|
||||
cfg.Activity = activity.DefaultActivityID
|
||||
}
|
||||
if cfg.TimeAPIURL == "" {
|
||||
if cfg.TimeAPIURL == "" || cfg.TimeAPIURL == constants.LegacyDefaultTimeAPI {
|
||||
cfg.TimeAPIURL = constants.DefaultTimeAPI
|
||||
}
|
||||
if cfg.Concurrency <= 0 {
|
||||
@@ -242,6 +243,12 @@ func normalizeProxyConfig(cfg *types.Config) {
|
||||
if cfg.AccountsPerProxy > constants.MaxAccountsPerProxy {
|
||||
cfg.AccountsPerProxy = constants.MaxAccountsPerProxy
|
||||
}
|
||||
if cfg.ProxySparePercent <= 0 {
|
||||
cfg.ProxySparePercent = constants.DefaultProxySparePercent
|
||||
}
|
||||
if cfg.ProxySparePercent > constants.MaxProxySparePercent {
|
||||
cfg.ProxySparePercent = constants.MaxProxySparePercent
|
||||
}
|
||||
}
|
||||
|
||||
// normalizeXiaodianConfig 约束和平小店分页参数,接口单页最大为 200。
|
||||
|
||||
Reference in New Issue
Block a user