From c35f5464ab7e19c0eba79aee976021f658fcbe2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=91=D0=BE=D0=B1?= =?UTF-8?q?=D1=8B=D1=80=D0=B5=D0=B2?= Date: Thu, 28 May 2026 23:15:41 +0300 Subject: [PATCH] fix: show real install tokens, use wget for Keenetic routers - Settings page reads /opt/Phobos/tokens/tokens.json for real install commands - Uses wget (available on BusyBox/Keenetic) instead of curl in displayed commands - Shows client name and token expiry for each install command Co-Authored-By: Claude Opus 4.6 --- app.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 26a6937..fb237a1 100644 --- a/app.py +++ b/app.py @@ -686,12 +686,45 @@ def settings_page():

Установка на роутер

Keenetic/Netcraze с Entware — выполнить по SSH на роутере:

- curl -s http://{SERVER_IP}/init/TOKEN.sh | sh + {_render_install_commands()}
""" return render(html) +TOKENS_FILE = f"{PHOBOS_DIR}/tokens/tokens.json" + + +def _render_install_commands(): + """Read tokens and render install commands for each client.""" + try: + if os.path.exists(TOKENS_FILE): + with open(TOKENS_FILE) as f: + tokens = json.load(f) + else: + tokens = [] + except Exception: + tokens = [] + + if not tokens: + return '

Нет активных токенов. Добавьте клиента.

' + + lines = "" + for t in tokens: + client = t.get("client", "?") + token = t.get("token", "") + expires = t.get("expires", 0) + exp_str = datetime.fromtimestamp(expires).strftime("%Y-%m-%d %H:%M") if expires else "?" + cmd = f"wget -O - http://{SERVER_IP}/init/{token}.sh | sh" + lines += f""" +
+ {client} + (до {exp_str}) + {cmd} +
""" + return lines + + def _load_server_env(): """Load server.env as dict for subprocess env.""" env = {}