1.0.3 - poprawa wydajności panelu
Wydanie WGTools-Extended / release (push) Successful in 12s

This commit is contained in:
asminme committed 2026-10-30 03:20:21 +01:00
1 parent aadc19341d
commit 3841e93e32
13 files changed
+73 -24

No files matched your search

+1
View File
@@ -98,6 +98,7 @@ def init_audit_database() -> None:
details TEXT NOT NULL DEFAULT ''
);
CREATE INDEX IF NOT EXISTS idx_audit_log_created_at ON audit_log(created_at DESC);
CREATE INDEX IF NOT EXISTS idx_audit_connection_lookup ON audit_log(action, object, created_at DESC, id DESC);
CREATE TABLE IF NOT EXISTS audit_wg_connection_state (
interface TEXT NOT NULL,
public_key TEXT NOT NULL,
+3 -2
View File
@@ -76,8 +76,9 @@ def init_database() -> None:
conn.execute("ALTER TABLE user_access ADD COLUMN permissions TEXT NOT NULL DEFAULT '{}'")
def get_user_access(user_id: int) -> dict[str, Any]:
init_database()
def get_user_access(user_id: int, *, initialize: bool = True) -> dict[str, Any]:
if initialize:
init_database()
with _connect() as conn:
row = conn.execute("SELECT role,interfaces,permissions FROM user_access WHERE user_id=?", (int(user_id),)).fetchone()
if row is None:
+14 -6
View File
@@ -13,9 +13,8 @@ DEFAULT_BACKUP_RETENTION = 20
def get_branding() -> dict[str, Any]:
return {"name": _get("brand_name", "WGTools-Extended"),
"color": _get("brand_color", "#8f1f27"),
"logo": _get("brand_logo", "")}
values = _get_many({"brand_name": "WGTools-Extended", "brand_color": "#8f1f27", "brand_logo": ""})
return {"name": values["brand_name"], "color": values["brand_color"], "logo": values["brand_logo"]}
def update_branding(name: str, color: str, logo: str) -> dict[str, Any]:
@@ -68,6 +67,14 @@ def _get(key: str, default: str) -> str:
return str(row["value"]) if row else default
def _get_many(defaults: dict[str, str]) -> dict[str, str]:
init_preferences()
with _connect() as conn:
placeholders = ",".join("?" for _ in defaults)
rows = conn.execute(f"SELECT key,value FROM app_settings WHERE key IN ({placeholders})", tuple(defaults)).fetchall()
return {**defaults, **{str(row["key"]): str(row["value"]) for row in rows}}
def _set(key: str, value: str) -> None:
init_preferences()
with _connect() as conn:
@@ -81,9 +88,10 @@ def _set(key: str, value: str) -> None:
def get_preferences() -> dict[str, Any]:
refresh = int(_get("refresh_seconds", str(REFRESH_SECONDS)))
threshold = int(_get("online_threshold_seconds", str(ONLINE_THRESHOLD_SECONDS)))
retention = int(_get("backup_retention", str(DEFAULT_BACKUP_RETENTION)))
values = _get_many({"refresh_seconds": str(REFRESH_SECONDS), "online_threshold_seconds": str(ONLINE_THRESHOLD_SECONDS), "backup_retention": str(DEFAULT_BACKUP_RETENTION)})
refresh = int(values["refresh_seconds"])
threshold = int(values["online_threshold_seconds"])
retention = int(values["backup_retention"])
return {
"refresh_seconds": max(2, min(refresh, 60)),
"online_threshold_seconds": max(30, min(threshold, 3600)),
+1 -1
View File
@@ -7,7 +7,7 @@ APP_NAME = "WGTools-Extended"
VERSION = Path(__file__).resolve().parents[2].joinpath("VERSION").read_text().strip()
WG_INTERFACE = os.getenv("WGTOOLS_INTERFACE", "wg0")
HELPER_PATH = os.getenv("WGTOOLS_HELPER", "/usr/local/libexec/wgtools-helper")
REFRESH_SECONDS = int(os.getenv("WGTOOLS_REFRESH_SECONDS", "5"))
REFRESH_SECONDS = int(os.getenv("WGTOOLS_REFRESH_SECONDS", "10"))
ONLINE_THRESHOLD_SECONDS = int(os.getenv("WGTOOLS_ONLINE_THRESHOLD_SECONDS", "180"))
DATABASE_PATH = os.getenv("WGTOOLS_DATABASE", "/var/lib/wgtools/wgtools.db")
SESSION_KEY_FILE = os.getenv("WGTOOLS_SESSION_KEY_FILE", "/var/lib/wgtools/session.key")