feat: 优化代理准备并完善远端部署
- 增加严格代理、两分钟预取、白名单去重与分组状态展示\n- 增加远端注册令牌和安全地址校验\n- 增加 Docker Compose、Caddy 示例与控制中心部署文档
This commit is contained in:
@@ -28,7 +28,8 @@ const (
|
||||
timeCalibrateRounds = 3
|
||||
timeCalibrateWait = 1200 * time.Millisecond
|
||||
resyncBeforeTrigger = 8 * time.Second
|
||||
proxyFetchBeforeTrigger = 30 * time.Second
|
||||
proxyFetchBeforeTrigger = 120 * time.Second
|
||||
proxyReadyDeadline = 15 * time.Second
|
||||
calibrationHistorySize = 3
|
||||
maxCooldownCount = 5
|
||||
xiaodianDefaultDelay = 500 * time.Millisecond
|
||||
@@ -68,6 +69,8 @@ type Scheduler struct {
|
||||
accountClientsDirty bool
|
||||
accountClientsExpireAt time.Time
|
||||
proxyGroups map[*client.DouyuClient]*proxyRuntimeGroup
|
||||
proxyGroupHistory []types.ProxyGroupStatus
|
||||
accountProxyGroup map[string]int
|
||||
proxyStandbys []validatedProxy
|
||||
proxyClientPool []*client.DouyuClient
|
||||
proxyExcludedURLs map[string]struct{}
|
||||
@@ -120,6 +123,10 @@ type Scheduler struct {
|
||||
autoFetchProxyOnSchedule bool
|
||||
accountsPerProxy int
|
||||
proxySparePercent int
|
||||
proxyRequired bool
|
||||
proxyReady bool
|
||||
proxyState string
|
||||
proxyBlockedReason string
|
||||
autoWhitelist bool
|
||||
whitelistReplace bool
|
||||
whitelistPassword string
|
||||
@@ -465,6 +472,23 @@ func (s *Scheduler) IsRunning() bool {
|
||||
return s.running
|
||||
}
|
||||
|
||||
// ProxyRunGate reports whether a run may start under strict proxy mode.
|
||||
func (s *Scheduler) ProxyRunGate() (bool, string) {
|
||||
s.proxyMu.RLock()
|
||||
defer s.proxyMu.RUnlock()
|
||||
if !s.proxyEnabled || !s.proxyRequired {
|
||||
return true, ""
|
||||
}
|
||||
if s.proxyReady {
|
||||
return true, ""
|
||||
}
|
||||
reason := s.proxyBlockedReason
|
||||
if reason == "" {
|
||||
reason = "代理尚未就绪"
|
||||
}
|
||||
return false, reason
|
||||
}
|
||||
|
||||
func (s *Scheduler) stopRunChan() <-chan struct{} {
|
||||
s.runMu.Lock()
|
||||
defer s.runMu.Unlock()
|
||||
@@ -519,6 +543,10 @@ func (s *Scheduler) RunNow(accountProducts map[string]string) {
|
||||
logger.LogEvent("代理", "error", "分组代理准备失败,本次抢购不执行: %v", err)
|
||||
return
|
||||
}
|
||||
if ok, reason := s.ProxyRunGate(); !ok {
|
||||
logger.LogEvent("代理", "error", "严格代理模式未就绪,本次抢购不执行: %s", reason)
|
||||
return
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
deadline := start.Add(seckillMaxDuration)
|
||||
@@ -1194,6 +1222,10 @@ func (s *Scheduler) RunXiaodian(accountProducts map[string]string, attempts, del
|
||||
logger.LogEvent("代理", "error", "分组代理准备失败,本次和平小店抢购不执行: %v", err)
|
||||
return
|
||||
}
|
||||
if ok, reason := s.ProxyRunGate(); !ok {
|
||||
logger.LogEvent("代理", "error", "严格代理模式未就绪,本次和平小店抢购不执行: %s", reason)
|
||||
return
|
||||
}
|
||||
s.startXiaodianReport(accounts, products, reportSessionID)
|
||||
|
||||
stoppedAccounts := make(map[string]string)
|
||||
|
||||
Reference in New Issue
Block a user