1.0.5 - opisy usług w przekierowaniach
Wydanie WGTools-Extended / release (push) Successful in 11s

This commit is contained in:
asminme committed 2026-10-30 13:15:39 +01:00
1 parent 6e7eaa9282
commit f4929c7cac
12 files changed
+155 -16

No files matched your search

+18
View File
@@ -4,6 +4,7 @@ import sqlite3
import time
import re
import base64
import json
from pathlib import Path
from typing import Any
@@ -12,6 +13,23 @@ from .settings import DATABASE_PATH, ONLINE_THRESHOLD_SECONDS, REFRESH_SECONDS
DEFAULT_BACKUP_RETENTION = 20
def get_service_policy() -> dict[str, Any]:
return json.loads(_get('forward_service_policy', '{"enabled":false,"mode":"list","services":[]}'))
def update_service_policy(enabled: bool, mode: str, services: list[str]) -> dict[str, Any]:
if mode not in {'list', 'custom', 'combo'}:
raise ValueError('Nieprawidłowy tryb usług')
services = list(dict.fromkeys(s.strip() for s in services if s.strip()))
if len(services) > 1000 or any(len(s) > 120 or any(ord(c) < 32 for c in s) or s.casefold() == 'other' for s in services):
raise ValueError('Nieprawidłowa lista usług')
if enabled and mode in {'list', 'combo'} and not services:
raise ValueError('Dodaj co najmniej jedną usługę do listy')
policy = {'enabled': enabled, 'mode': mode, 'services': services}
_set('forward_service_policy', json.dumps(policy, ensure_ascii=True))
return policy
def get_branding() -> dict[str, Any]:
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"]}