docs: document control API
Add API section to README (features, CLI, config), PROJECT (architecture), USAGE (full endpoint reference with examples), CHEATSHEET (curl one-liners). Update TASKS and ROADMAP. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,7 @@ log_level: info
|
||||
max_connections: 256 # concurrent connection limit (backpressure)
|
||||
pool_size: 0 # pre-warmed TCP connections to first hop (0 = disabled)
|
||||
pool_max_idle: 30 # max idle time for pooled connections (seconds)
|
||||
api_listen: "" # control API bind address (empty = disabled)
|
||||
|
||||
chain:
|
||||
- socks5://127.0.0.1:9050
|
||||
@@ -216,6 +217,70 @@ other pool settings).
|
||||
The old `proxy_source` key is still supported and auto-converts to `proxy_pool`
|
||||
with a single API source. `proxy_pool` takes precedence if both are present.
|
||||
|
||||
## Control API
|
||||
|
||||
Built-in HTTP API for runtime inspection and management. Disabled by default;
|
||||
enable with `api_listen` in config or `--api` on the command line.
|
||||
|
||||
```yaml
|
||||
api_listen: 127.0.0.1:1081
|
||||
```
|
||||
|
||||
```bash
|
||||
s5p --api 127.0.0.1:1081 -c config/s5p.yaml
|
||||
```
|
||||
|
||||
### Read endpoints
|
||||
|
||||
| Method | Path | Description |
|
||||
|--------|------|-------------|
|
||||
| `GET` | `/status` | Combined summary: uptime, metrics, pool stats, chain |
|
||||
| `GET` | `/metrics` | Full metrics counters (connections, bytes, uptime) |
|
||||
| `GET` | `/pool` | All proxies with per-entry state |
|
||||
| `GET` | `/pool/alive` | Alive proxies only |
|
||||
| `GET` | `/config` | Current runtime config (sanitized) |
|
||||
|
||||
### Write endpoints
|
||||
|
||||
| Method | Path | Description |
|
||||
|--------|------|-------------|
|
||||
| `POST` | `/reload` | Re-read config file (replaces SIGHUP) |
|
||||
| `POST` | `/pool/test` | Trigger immediate health test cycle |
|
||||
| `POST` | `/pool/refresh` | Trigger immediate source re-fetch |
|
||||
|
||||
All responses are `application/json`. Errors return `{"error": "message"}` with
|
||||
appropriate status code (400, 404, 405, 500).
|
||||
|
||||
### Examples
|
||||
|
||||
```bash
|
||||
# Runtime status
|
||||
curl -s http://127.0.0.1:1081/status | jq .
|
||||
|
||||
# Full metrics
|
||||
curl -s http://127.0.0.1:1081/metrics | jq .
|
||||
|
||||
# Pool state (all proxies)
|
||||
curl -s http://127.0.0.1:1081/pool | jq .
|
||||
|
||||
# Alive proxies only
|
||||
curl -s http://127.0.0.1:1081/pool/alive | jq '.proxies | length'
|
||||
|
||||
# Current config
|
||||
curl -s http://127.0.0.1:1081/config | jq .
|
||||
|
||||
# Reload config (like SIGHUP)
|
||||
curl -s -X POST http://127.0.0.1:1081/reload | jq .
|
||||
|
||||
# Trigger health tests now
|
||||
curl -s -X POST http://127.0.0.1:1081/pool/test | jq .
|
||||
|
||||
# Re-fetch proxy sources now
|
||||
curl -s -X POST http://127.0.0.1:1081/pool/refresh | jq .
|
||||
```
|
||||
|
||||
Settings that require a restart: `listen`, `chain`, `pool_size`, `pool_max_idle`, `api_listen`.
|
||||
|
||||
## Connection Retry
|
||||
|
||||
When a proxy pool is active, s5p retries failed connections with a different
|
||||
@@ -250,7 +315,7 @@ Settings reloaded on SIGHUP:
|
||||
| `max_connections` | Concurrent connection limit |
|
||||
| `proxy_pool.*` | Sources, intervals, thresholds |
|
||||
|
||||
Settings that require a restart: `listen`, `chain`, `pool_size`, `pool_max_idle`.
|
||||
Settings that require a restart: `listen`, `chain`, `pool_size`, `pool_max_idle`, `api_listen`.
|
||||
|
||||
Requires `-c` / `--config` to know which file to re-read. Without a
|
||||
config file, SIGHUP is ignored with a warning.
|
||||
|
||||
Reference in New Issue
Block a user