Gatherer: aggregate several sessions of one user under the account

Session key uses the OpenVPN Client ID (survives float), one usage_history
row per user per tick, summed speeds in the API, last_bytes/real_address
per account, migration 2 (active_sessions.session_id). Also throttles the
"status file missing" log and reports recovery.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5.5 committed 2026-10-07 09:38:09 +03:00
1 parent ad6995bb63
commit 7d6f44c965
11 files changed
+287 -57

No files matched your search

+9
View File
@@ -459,8 +459,17 @@ def _m001_baseline(conn):
_ensure_column('users', 'is_2fa_enabled', 'INTEGER DEFAULT 0')
def _m002_session_id(conn):
"""active_sessions.session_id: the Client ID of the session from the OpenVPN v2 status
(part of the gatherer's session key). NULL is allowed: rows of an old snapshot and a
status without the Client ID column."""
if not any(row[1] == "session_id" for row in conn.execute("PRAGMA table_info(active_sessions)")):
conn.execute("ALTER TABLE active_sessions ADD COLUMN session_id TEXT")
MIGRATIONS = [
Migration(1, "baseline", _m001_baseline),
Migration(2, "session_id", _m002_session_id),
]
# No separate "fresh" schema: the baseline migration creates everything on a new database