mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-03 11:01:22 +08:00
feat(health-check): replace real-LLM probe with HTTP reachability check
The provider panel health check sent a real streaming model request, which many third-party providers block (401/403/WAF), causing false negatives while only stable official endpoints passed. Replace it with a lightweight reachability probe: GET the provider base_url and treat any HTTP response (200/4xx/5xx) as reachable; only DNS/connect/TLS/timeout count as failure. Latency is the probe's TTFB. Backend (services/stream_check.rs): rewrite ~2200 -> ~350 lines, dropping real-request building, format conversion, auth and API-path resolution while keeping per-app base_url extraction. Defaults: 8s timeout, 1 retry, 1500ms degraded threshold. Failover invariant: the reachability check must never reset the circuit breaker (reachable != usable; a 403 host is reachable but broken for real traffic). Remove the resetCircuitBreaker call from useStreamCheck; failover failure detection stays driven solely by real proxy traffic (forwarder/circuit_breaker untouched). useResetCircuitBreaker is kept dormant for a future manual-recovery entry. Open the check to all providers: drop the official/copilot/codex-oauth/third-party gating and the 'sends a real request' confirm dialog. For official providers whose base_url is intentionally empty, fall back to the endpoint the client actually uses (Claude -> api.anthropic.com, Codex -> chatgpt.com/backend-api/codex, Gemini -> generativelanguage). Non-official providers with a missing base_url still error to avoid a false green light. Claude Desktop Official is native 1P mode (talks to claude.ai, cc-switch not in the request path, no reliable endpoint) so its button stays hidden. Slim StreamCheckConfig and per-provider testConfig to timeout/threshold/retries (drop test model + prompt); sync zh/en/ja/zh-TW. Retain the now-unused anthropic_to_openai/anthropic_to_gemini transform utilities and their test suites.
This commit is contained in:
@@ -98,6 +98,7 @@
|
||||
"windowClose": "Close window"
|
||||
},
|
||||
"provider": {
|
||||
"connectivityCheck": "Connectivity check",
|
||||
"tabProvider": "Provider",
|
||||
"tabUniversal": "Universal",
|
||||
"noProviders": "No providers added yet",
|
||||
@@ -2515,6 +2516,11 @@
|
||||
"stopWithRestoreFailed": "Stop failed: {{detail}}"
|
||||
},
|
||||
"streamCheck": {
|
||||
"reachable": "{{providerName}} is reachable ({{responseTimeMs}}ms)",
|
||||
"reachableSlow": "{{providerName}} reachable but slow ({{responseTimeMs}}ms)",
|
||||
"unreachable": "{{providerName}} unreachable: {{message}}",
|
||||
"unreachableHint": "Could not establish a connection (DNS / connect / TLS / timeout). Check the base_url and your network.",
|
||||
"connectivityNote": "Connectivity check only probes whether the provider address is reachable; it does not send a real model request. Any response counts as \"reachable\" — which does not guarantee that auth or model settings are correct.",
|
||||
"configSaved": "Health check config saved",
|
||||
"configSaveFailed": "Save failed",
|
||||
"testModels": "Test Models",
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
"windowClose": "ウィンドウを閉じる"
|
||||
},
|
||||
"provider": {
|
||||
"connectivityCheck": "接続チェック",
|
||||
"tabProvider": "プロバイダー",
|
||||
"tabUniversal": "統一プロバイダー",
|
||||
"noProviders": "まだプロバイダーがありません",
|
||||
@@ -2515,6 +2516,11 @@
|
||||
"stopWithRestoreFailed": "停止に失敗しました: {{detail}}"
|
||||
},
|
||||
"streamCheck": {
|
||||
"reachable": "{{providerName}} は接続可能 ({{responseTimeMs}}ms)",
|
||||
"reachableSlow": "{{providerName}} は接続可能だが低速 ({{responseTimeMs}}ms)",
|
||||
"unreachable": "{{providerName}} に接続できません: {{message}}",
|
||||
"unreachableHint": "接続を確立できませんでした(DNS / 接続 / TLS / タイムアウト)。base_url とネットワークを確認してください。",
|
||||
"connectivityNote": "接続チェックはプロバイダーのアドレスに到達できるかを確認するだけで、実際のモデルリクエストは送信しません。何らかの応答があれば「到達可能」とみなされますが、認証やモデル設定が正しいことを保証するものではありません。",
|
||||
"configSaved": "ヘルスチェック設定を保存しました",
|
||||
"configSaveFailed": "保存に失敗しました",
|
||||
"testModels": "テストモデル",
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
"windowClose": "關閉視窗"
|
||||
},
|
||||
"provider": {
|
||||
"connectivityCheck": "檢測連通",
|
||||
"tabProvider": "供應商",
|
||||
"tabUniversal": "通用供應商",
|
||||
"noProviders": "尚未新增任何供應商",
|
||||
@@ -2487,6 +2488,11 @@
|
||||
"stopWithRestoreFailed": "停止失敗:{{detail}}"
|
||||
},
|
||||
"streamCheck": {
|
||||
"reachable": "{{providerName}} 連通正常 ({{responseTimeMs}}ms)",
|
||||
"reachableSlow": "{{providerName}} 連通但較慢 ({{responseTimeMs}}ms)",
|
||||
"unreachable": "{{providerName}} 無法連通: {{message}}",
|
||||
"unreachableHint": "無法建立連線(DNS / 連線 / TLS / 逾時)。請檢查 base_url 與網路。",
|
||||
"connectivityNote": "連通檢測僅探測供應商位址是否可達,不發送真實模型請求。收到任意回應即視為「可達」——這不代表驗證或模型設定一定正確。",
|
||||
"configSaved": "健康檢測設定已儲存",
|
||||
"configSaveFailed": "儲存失敗",
|
||||
"testModels": "測試模型",
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
"windowClose": "关闭窗口"
|
||||
},
|
||||
"provider": {
|
||||
"connectivityCheck": "检测连通",
|
||||
"tabProvider": "供应商",
|
||||
"tabUniversal": "统一供应商",
|
||||
"noProviders": "还没有添加任何供应商",
|
||||
@@ -2515,6 +2516,11 @@
|
||||
"stopWithRestoreFailed": "停止失败: {{detail}}"
|
||||
},
|
||||
"streamCheck": {
|
||||
"reachable": "{{providerName}} 连通正常 ({{responseTimeMs}}ms)",
|
||||
"reachableSlow": "{{providerName}} 连通但较慢 ({{responseTimeMs}}ms)",
|
||||
"unreachable": "{{providerName}} 无法连通: {{message}}",
|
||||
"unreachableHint": "无法建立连接(DNS / 连接 / TLS / 超时)。请检查 base_url 与网络。",
|
||||
"connectivityNote": "连通检测仅探测供应商地址是否可达,不发送真实模型请求。收到任意响应即视为“可达”——这不代表鉴权或模型配置一定正确。",
|
||||
"configSaved": "健康检查配置已保存",
|
||||
"configSaveFailed": "保存失败",
|
||||
"testModels": "测试模型",
|
||||
|
||||
Reference in New Issue
Block a user