proxy-pilot 0.7.1

Core-agnostic proxy health monitor, automatic failover daemon, and multi-channel alerting tool for Linux servers.
Documentation
# Configuration Reference

The live configuration file is stored at `/etc/proxy-pilot/config.yaml` (never commit it to Git; commit only `config.example.yaml`).

## Sections

### `core`
Defines which proxy core `proxy-pilot` manages.

| Key | Type | Default | Description |
| --- | --- | --- | --- |
| `kind` | string | `"xray"` | Proxy core adapter (`"xray"`; planned: `"singbox"`). |
| `binary_path` | string | `"/var/lib/proxy-pilot/bin/xray"` | Path to the managed core binary. |
| `config_path` | string | `"/usr/local/etc/xray/config.json"` | Path to the core's runtime config file (updated atomically). |
| `service_name` | string | `"xray"` | `systemd` service name for reloading/restarting the core. |
| `local_proxy` | string | `"socks5h://127.0.0.1:10808"` | Fixed local proxy endpoint used by health probes. |

### `routing` (Planned)
Controls how traffic sent to the fixed local proxy is routed without enabling TUN mode:
- `mode: "whitelist"` (recommended on Iran servers): Only listed domains (`telegram.org`, `googleapis.com`, `docker.io`, `youtube.com`, etc.) go through the proxy tunnel; everything else goes `direct`.
- `mode: "bypass_ir"`: All traffic goes through the proxy tunnel except `geosite:ir` and `geoip:ir`.

### `profiles`
Ordered list of proxy outbound profiles (`name`, `outbound_tag`, `priority`). Lower `priority` number = higher preference during failover.

### `probe`
Controls health checks, anti-flapping, periodic re-benchmarking, and auto-recovery:
- `interval_secs`: Seconds between active-profile health checks (recommended `15`–`30` in production; `5` for fast detection). Only the single active profile is probed, so resource usage is constant regardless of profile count.
- `timeout_secs`: Per-target HTTP timeout in seconds (recommended `8`).
- `failure_threshold`: Consecutive failures before switching away from the active profile (default `3`).
- `recovery_threshold`: Consecutive successes before marking an unhealthy profile healthy again (default `2`).
- `max_latency_ms`: Optional latency ceiling in milliseconds; responses slower than this count as a failure.
- `benchmark_interval_secs`: Interval in seconds for non-disruptive parallel background re-benchmarking of all profiles (default `900` = 15 minutes; set `0` to disable).
- `auto_prune_after_hours`: Automatically remove profiles that remain continuously unhealthy across background benchmarks for this many hours (default `24`; set `0` to disable). Safety guards ensure pruning never runs when 0 healthy profiles remain or when the host server's own direct internet check fails.
- `direct_check_url`: Optional direct (non-proxied) URL used to verify the host server's own internet connectivity before auto-pruning dead profiles. On Iran servers, a domestic site such as `"https://www.aparat.com"` works well; on servers in other restricted or censored regions, set any locally reachable URL (or omit to skip the direct check).
- `targets`: List of `{ name, url, expected_status, blocked_status }` checked through `local_proxy` to distinguish tunnel outages from IP geo-blocks (`403` / `429`).

#### Tuning & Client Retry Guidance
- **Failover detection window:** A real outage takes roughly `interval_secs × failure_threshold` seconds to confirm, plus `< 1s` (~400ms) for `xray` to reload onto the next profile.
- **Avoiding false-positive reloads:** Overly aggressive values (such as `interval_secs: 5`, `timeout_secs: 4`) can trigger unnecessary switches during brief network jitter. Using `interval_secs: 15`, `timeout_secs: 8`, `failure_threshold: 3`, and `max_latency_ms: 4000` is a balanced production baseline.
- **Zero-loss client retries:** Applications that send periodic requests through the local proxy (e.g., a bot posting to Telegram every minute) should use a retry window longer than the failover detection window (for example, exponential backoff `3s -> 6s -> 12s -> 20s`) or queue failed messages for the next cycle so a request that lands right when a profile dies still succeeds after failover completes.

### `notify`
Controls VPN-independent alerts:
- `cooldown_secs`: Minimum seconds between repeated alerts of the same type (default `300`).
- `bale`: `{ enabled, bot_token, chat_id }`. In production, prefer setting `BALE_BOT_TOKEN` via environment variable instead of storing the raw token in `config.yaml`.