mirror of
https://github.com/anten-ka/gotelegram_pro.git
synced 2026-05-19 18:26:07 +00:00
v2.5.0: redact admin overview secret
This commit is contained in:
@@ -43,6 +43,7 @@ PORT = int(os.getenv("GOTELEGRAM_ADMIN_PORT", "1984"))
|
||||
VERSION = "2.5.0"
|
||||
USER_RE = re.compile(r"^[A-Za-z0-9_.-]{1,48}$")
|
||||
LANG_RE = re.compile(r"^(en|ru)$")
|
||||
SENSITIVE_CONFIG_KEYS = {"secret"}
|
||||
|
||||
|
||||
def utc_now() -> str:
|
||||
@@ -91,6 +92,10 @@ def read_language(config: dict[str, Any] | None = None) -> str:
|
||||
return lang if lang in {"en", "ru"} else "en"
|
||||
|
||||
|
||||
def public_config(config: dict[str, Any]) -> dict[str, Any]:
|
||||
return {key: value for key, value in config.items() if key not in SENSITIVE_CONFIG_KEYS}
|
||||
|
||||
|
||||
def write_language(lang: str) -> dict[str, Any]:
|
||||
lang = str(lang or "").strip().lower()
|
||||
if not LANG_RE.match(lang):
|
||||
@@ -488,7 +493,7 @@ def overview_payload() -> dict[str, Any]:
|
||||
"time": utc_now(),
|
||||
"language": language,
|
||||
"admin_bind": {"host": HOST, "port": PORT},
|
||||
"config": config,
|
||||
"config": public_config(config),
|
||||
"site_status": site_status(config),
|
||||
"users_count": len(users),
|
||||
"services": services,
|
||||
|
||||
Reference in New Issue
Block a user