fix: server health ping, rate limiting, security hardening, DA backoff
- Server health ping every 30s — dead servers excluded from all API calls, auto-recovered when back online - Fixed py3xui client.delete() argument order (inbound_id first, client_uuid second) - Rate limiting on /admin/login (max 10 attempts per 60s per IP) - XSS prevention: HTML-escape all user-controlled fields in templates - CSP headers on all HTML pages (CSP, X-Frame-Options, X-Content-Type-Options) - CORS restricted to configured host instead of wildcard - Secure + SameSite=Lax cookie flags for admin_token - Bind to 127.0.0.1 instead of 0.0.0.0 - Async locks for global state (last_donation_id) - Graceful shutdown: all background tasks cancelled on exit - DA polling exponential backoff: 1s→max 1h, immediate 1h on 401
This commit is contained in:
@@ -35,6 +35,12 @@ aggregator.py ──→ FastAPI сервер
|
|||||||
- **ShortID ротация**: автоматическая смена shortId на серверах каждые N часов
|
- **ShortID ротация**: автоматическая смена shortId на серверах каждые N часов
|
||||||
- **MOTD**: объявления из motd.txt или settings
|
- **MOTD**: объявления из motd.txt или settings
|
||||||
- **Health scoring**: взвешенная оценка здоровья сервера (CPU 30%, RAM 25%, Disk 20%, Net 15%, I/O 10%)
|
- **Health scoring**: взвешенная оценка здоровья сервера (CPU 30%, RAM 25%, Disk 20%, Net 15%, I/O 10%)
|
||||||
|
- **Server health ping**: фоновый пинг всех серверов каждые 30с — dead сервера автоматически исключаются из подписки, трафика, ротации shortid и админки
|
||||||
|
- **Auto-recovery**: при возвращении сервера в сеть он снова включается в работу без перезагрузки
|
||||||
|
- **Rate limiting**: не более 10 попыток входа в админку за 60с с одного IP
|
||||||
|
- **DA polling backoff**: при ошибках DonationAlerts API интервал удваивается до 1ч, при 401 — сразу 1ч ожидания
|
||||||
|
- **CSP + XSS protection**: Content-Security-Policy на всех HTML-страницах, экранирование user-контролируемых полей
|
||||||
|
- **Graceful shutdown**: все фоновые задачи корректно завершаются при остановке
|
||||||
- **Trojan support**: создание клиентов на Trojan инбаундах (password вместо uuid)
|
- **Trojan support**: создание клиентов на Trojan инбаундах (password вместо uuid)
|
||||||
|
|
||||||
## wdtt (Zern-BlackOut) Compatibility
|
## wdtt (Zern-BlackOut) Compatibility
|
||||||
@@ -213,10 +219,13 @@ curl -X POST http://localhost:8000/admin/api/propagate/{server_name} -b "admin_t
|
|||||||
|
|
||||||
## DonationAlerts
|
## DonationAlerts
|
||||||
|
|
||||||
Polling-based (every ~2 seconds). Amount mapping from `settings.conf → tiers → prices`:
|
Polling-based с adaptive backoff. Amount mapping from `settings.conf → tiers → prices`:
|
||||||
- Any configured amount → corresponding tier + days
|
- Any configured amount → corresponding tier + days
|
||||||
- Donor identified by `id` or `username` from donation message
|
- Donor identified by `id` or `username` from donation message
|
||||||
- `tariff_end_at` extends dynamically (MAX of current end, now + days)
|
- `tariff_end_at` extends dynamically (MAX of current end, now + days)
|
||||||
|
- При ошибках API интервал удваивается (1 → 2 → 4 → ... → 3600с)
|
||||||
|
- При 401 Unauthorized — сразу 1ч ожидания (токен невалиден)
|
||||||
|
- После успешного ответа интервал сбрасывается к базовому
|
||||||
|
|
||||||
## Happ.su / WDTT Support
|
## Happ.su / WDTT Support
|
||||||
|
|
||||||
@@ -228,10 +237,14 @@ Subscription response includes compatible headers:
|
|||||||
|
|
||||||
## Tech
|
## Tech
|
||||||
|
|
||||||
- **FastAPI** + uvicorn
|
- **FastAPI** + uvicorn (bind на `127.0.0.1` — за reverse proxy)
|
||||||
- **SQLite** (users only)
|
- **SQLite** (users only)
|
||||||
- **py3xui** — 3x-UI API client
|
- **py3xui** — 3x-UI API client
|
||||||
- **httpx** — async HTTP for sub links
|
- **httpx** — async HTTP for sub links + server health pings
|
||||||
- **qrcode** — QR generation
|
- **qrcode** — QR generation
|
||||||
- **Plus Jakarta Sans / JetBrains Mono** — UI typography
|
- **Plus Jakarta Sans / JetBrains Mono** — UI typography
|
||||||
- **Glassmorphism** — design system
|
- **Glassmorphism** — design system
|
||||||
|
- **CSP + Security headers** — Content-Security-Policy, X-Frame-Options, X-Content-Type-Options на всех страницах
|
||||||
|
- **CORS** — ограничен до домена из конфига
|
||||||
|
- **Rate limiting** — in-memory на `/admin/login`
|
||||||
|
- **Server health** — фоновый пинг каждые 30с, автоисключение dead серверов
|
||||||
|
|||||||
+497
-374
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user