feat: add planned session rotation

This commit is contained in:
cyber-debug
2026-05-16 00:49:52 +03:00
parent 4c6bd2b838
commit 82b5741ab1
10 changed files with 288 additions and 86 deletions

View File

@@ -26,6 +26,10 @@ liveness:
timeout: 5s
failures: 3
# Optional planned rebuild for long-running calls.
# lifecycle:
# max_session_duration: 6h
# Local SOCKS5 listener exposed to applications
socks:
host: "127.0.0.1"

View File

@@ -34,6 +34,7 @@ olcrtc /etc/olcrtc/server.yaml
| `liveness.interval` | control-stream ping interval, default `10s` |
| `liveness.timeout` | pong timeout, default `5s` |
| `liveness.failures` | missed pongs before reconnect, default `3` |
| `lifecycle.max_session_duration` | planned session rebuild interval, e.g. `6h`; unset = off |
| `gen.amount` | gen mode: number of rooms to create |
| `profiles[]` | ordered srv/cnc failover profiles |
| `failover.retry_delay` | delay before trying the next profile, e.g. `2s` |
@@ -67,6 +68,24 @@ When the failure threshold is reached, the current smux session is rebuilt.
In failover mode, a profile that exits after liveness-triggered reconnect
failure lets the supervisor advance to the next profile.
## Lifecycle Rotation
`lifecycle.max_session_duration` sets a planned upper bound for one provider
call/session. When the duration expires, olcrtc cancels the active server or
client session and starts a fresh one with the same config. While this option
is enabled, clean session endings are also restarted so the peer that did not
fire the timer can follow the rebuild. This is useful for long-running
deployments where provider calls get stale, accumulate media state, or should
be periodically re-created.
```yaml
lifecycle:
max_session_duration: 6h
```
The field is optional and disabled when omitted. Values use Go duration syntax
such as `30m`, `2h`, or `6h`; zero and negative durations are rejected.
## Failover Profiles
`mode: srv` and `mode: cnc` can define `profiles`. Top-level fields are used

View File

@@ -15,6 +15,10 @@ liveness:
timeout: 5s
failures: 3
# Optional planned rebuild for each active profile.
# lifecycle:
# max_session_duration: 6h
data: data
profiles:

View File

@@ -304,6 +304,7 @@ Implemented:
- `failover.retry_delay`.
- `failover.max_cycles`.
- Profile start/end logs.
- Planned session rotation with `lifecycle.max_session_duration`.
Still valuable:

View File

@@ -28,6 +28,10 @@ liveness:
timeout: 5s
failures: 3
# Optional planned rebuild for long-running calls.
# lifecycle:
# max_session_duration: 6h
# Outbound SOCKS5 proxy for server-side egress (optional)
socks:
proxy_addr: "" # e.g. "127.0.0.1"

View File

@@ -66,6 +66,7 @@
| `liveness.interval` | Интервал ping по control stream, по умолчанию `10s` |
| `liveness.timeout` | Сколько ждать pong, по умолчанию `5s` |
| `liveness.failures` | Сколько pong можно пропустить перед rebuild, по умолчанию `3` |
| `lifecycle.max_session_duration` | Плановый rebuild сессии после указанного времени, например `6h`; если поле не задано, выключено |
`crypto.key_file` читается относительно YAML-файла. Не указывай `crypto.key` и `crypto.key_file` одновременно.
@@ -78,6 +79,13 @@
а не только статус WebRTC/provider соединения. Если pong не приходит несколько
раз подряд, текущая smux-сессия пересоздается.
`lifecycle.max_session_duration` ограничивает длительность одного звонка /
provider session. Когда таймер истекает, текущая `srv` или `cnc` сессия
закрывается и стартует заново с тем же конфигом. Пока эта настройка включена,
чистое завершение сессии тоже перезапускается, чтобы второй peer мог догнать
плановый rebuild. Формат значения: `30m`, `2h`, `6h`; `0s` и отрицательные
значения не принимаются.
---
## mode: gen