Add shaping, Prometheus, monitor tab and peer audit

Baseline TypeScript version before the Go rewrite: CAKE fair sharing with
automatic deprioritisation of heavy devices, per-key priority, /metrics with
a metrics token, the built-in Prometheus install/remove, the Monitor tab,
grouped sidebar tabs and the dead-peer audit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 15:27:05 +03:00
co-authored by Claude Sonnet 5.5
parent 7fbff82e76
commit e9df363dd2
33 changed files with 2708 additions and 49 deletions
+15
View File
@@ -5,6 +5,9 @@
import axios from 'axios';
// Поколение протокола AmneziaWG, на параметрах которого выдан vpn:// ключ.
export type AwgGen = '2' | '3.1';
// Текущая приоритетность ключа/устройства: «background» — канал занят, а он давно качает больше своей доли.
export type Priority = 'normal' | 'background';
export interface User {
name: string;
ip: string;
@@ -15,6 +18,7 @@ export interface User {
lastHandshake: number;
rx?: number;
tx?: number;
priority?: Priority; // нет у awg-ctrl старше деления канала
}
export interface ServerInfo {
name: string;
@@ -64,6 +68,17 @@ export interface NodeInfo {
health: { server: string; ip: string; gen: AwgGen; peers: number; awg_up: boolean; module: string; tools: string } | null;
}
// Деление канала (GET/PUT /api/shaping на awg-ctrl сервера).
export interface ShapingStatus {
settings: { enabled: boolean; downMbit: number; upMbit: number; auto: boolean };
active: boolean; // CAKE реально стоит на интерфейсе
congested: boolean;
heavy: string[]; // IP устройств, переведённых в фоновый класс
devices: number; // активных устройств в окне
rateDown: number; // Мбит/с за последний тик
rateUp: number;
}
// Сравнение версий вида 0.3.3 (хвост после «-» не учитывается): <0 — a старше b.
export function cmpVersion(a: string, b: string): number {
const pa = a.split('-')[0].split('.').map(Number), pb = b.split('-')[0].split('.').map(Number);