feat: add connection retry and metrics
Retry failed proxy connections with a fresh random proxy on each attempt (configurable via retries setting, proxy_source only). Track connection metrics and log summary every 60s and on shutdown. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,7 @@ cp config/example.yaml config/s5p.yaml
|
||||
```yaml
|
||||
listen: 127.0.0.1:1080
|
||||
timeout: 10
|
||||
retries: 3 # max attempts per connection (proxy_source only)
|
||||
log_level: info
|
||||
|
||||
chain:
|
||||
@@ -101,6 +102,40 @@ s5p -C socks5://127.0.0.1:9050 -S http://10.200.1.250:8081/proxies
|
||||
The API must return JSON: `{"proxies": [{"proto": "socks5", "proxy": "host:port"}, ...]}`.
|
||||
Entries with `null` proto are skipped.
|
||||
|
||||
## Connection Retry
|
||||
|
||||
When `proxy_source` is active, s5p retries failed connections with a different
|
||||
random proxy. Controlled by the `retries` setting (default: 3). Static-only
|
||||
chains do not retry (retrying the same chain is pointless).
|
||||
|
||||
```yaml
|
||||
retries: 5 # try up to 5 different proxies per connection
|
||||
```
|
||||
|
||||
```bash
|
||||
s5p -r 5 -C socks5://127.0.0.1:9050 -S http://api:8081/proxies
|
||||
```
|
||||
|
||||
## Metrics
|
||||
|
||||
s5p tracks connection metrics and logs a summary every 60 seconds and on
|
||||
shutdown:
|
||||
|
||||
```
|
||||
metrics: conn=142 ok=98 fail=44 retries=88 active=3 in=1.2M out=4.5M up=0h05m12s
|
||||
```
|
||||
|
||||
| Counter | Meaning |
|
||||
|---------|---------|
|
||||
| `conn` | Total incoming connections |
|
||||
| `ok` | Successfully connected + relayed |
|
||||
| `fail` | All retries exhausted |
|
||||
| `retries` | Total retry attempts |
|
||||
| `active` | Currently relaying |
|
||||
| `in` | Bytes client -> remote |
|
||||
| `out` | Bytes remote -> client |
|
||||
| `up` | Server uptime |
|
||||
|
||||
## Profiling
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user