fix(proxy): make "Test All" read-only + add bulk enable/disable (#6246)

The 3.8.44 "Test All" button (POST /api/settings/proxies/auto-test) flipped a
proxy to inactive on a failed reachability probe; since the egress selector
excludes inactive proxies, a flaky probe (unreachable httpbin.org, a proxy that
blocks HEAD, a slow paid proxy) silently disabled every proxy that failed. Make
automated probes read-only by default via a shared statusPolicy helper (opt back
into test-and-set with PROXY_HEALTH_AUTO_DEACTIVATE=true), and add a bulk
enable/disable endpoint (POST /api/settings/proxies/batch-activate) + toolbar
action so an operator can re-activate proxies in one click.

Complements the core fail-closed + scheduler fix in #6296. TDD: tests/unit/proxy-health-6246.test.ts.

Co-authored-by: tenshiak <tenshiak@users.noreply.github.com>
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-07-05 16:32:22 -03:00
parent bf1481f11f
commit 482a77cbbc
11 changed files with 344 additions and 2 deletions

View File

@@ -836,6 +836,7 @@ Anthropic-compatible provider instead.
| `PROXY_HEALTH_ENABLED` | `true` | `src/lib/proxyHealth/scheduler.ts` | Set `false` to disable the background proxy health scheduler that periodically probes registered proxies. |
| `PROXY_HEALTH_INTERVAL_MS` | `600000` | `src/lib/proxyHealth/scheduler.ts` | Background health-scheduler sweep interval in ms (minimum `60000`). |
| `PROXY_HEALTH_TEST_URL` | `https://httpbin.org/ip` | `src/lib/proxyHealth/scheduler.ts` | Reachability probe target used by the scheduler and the `/api/settings/proxies/auto-test` endpoint. Point it at an internal/self-hosted URL to avoid the public default. |
| `PROXY_HEALTH_AUTO_DEACTIVATE` | `false` | `src/lib/proxyHealth/statusPolicy.ts` | When `false` (default), automated reachability probes (the scheduler + the `/api/settings/proxies/auto-test` "Test All" button) are **read-only** and never write a proxy's status — only the operator sets active/inactive, so a flaky probe can't strand an assigned proxy (#6246). Set `true` to restore the legacy test-and-set behaviour. |
| `PROXY_AUTO_REMOVE` | `false` | `src/lib/proxyHealth/scheduler.ts` | Set `true` to let the scheduler auto-remove proxies after repeated consecutive failures. |
| `PROXY_AUTO_REMOVE_AFTER` | `3` | `src/lib/proxyHealth/scheduler.ts` | Consecutive failures before the scheduler auto-removes a proxy (when `PROXY_AUTO_REMOVE=true`). |
| `OMNIROUTE_CONTROL_PLANE_PROXY_DIRECT_FALLBACK` | `false` | `src/shared/constants/featureFlagDefinitions.ts` | Allow OAuth and provider validation flows to bypass a pinned proxy and connect directly when proxy reachability pre-checks fail. Effective precedence is Feature Flags DB override > env var > default. |