MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / failover_proxy

Method failover_proxy

daily/chinaUnicom.py:379–393  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

377 self.log(f"🚫 重试{max_retries}次均失败,回退至本地IP")
378
379 def failover_proxy(self):
380 proxy_api = os.environ.get("UNICOM_PROXY_API")
381 if not proxy_api:
382 return False
383 self.log("⚠️ [故障转移] 检测到网络不稳定,正在检查当前代理是否存活...")
384 try:
385 requests.get("https://www.baidu.com", proxies=self.session.proxies, timeout=3)
386 self.log("✅ [故障转移] 经测试当前IP仍有效,继续复用,暂不提取新IP。")
387 time.sleep(1)
388 return True
389 except Exception as e:
390 self.log(f"❌ [故障转移] 当前代理已失效 ({e}),准备更换新IP...")
391 time.sleep(2)
392 self.configure_proxy()
393 return True
394
395 def init_account(self, config_str):
396 parts = config_str.split('#')

Callers 6

cloudRequestMethod · 0.95
getTicketByNative_secMethod · 0.95
openPlatLineNewMethod · 0.95
requestMethod · 0.80

Calls 4

logMethod · 0.95
configure_proxyMethod · 0.95
sleepMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected