mirror of
https://github.com/anten-ka/gotelegram_pro.git
synced 2026-05-19 15:36:03 +00:00
v2.5.0: remove local web admin token gate
This commit is contained in:
@@ -118,7 +118,6 @@ PROMO_STAMP_FILE = "/opt/gotelegram/.promo_bot_last_shown"
|
||||
BOT_TOKEN = os.getenv("BOT_TOKEN")
|
||||
ENV_FILE = "/opt/gotelegram-bot/.env"
|
||||
ADMIN_WEB_SERVICE = "gotelegram-admin"
|
||||
ADMIN_WEB_TOKEN_FILE = "/opt/gotelegram-admin/token"
|
||||
ADMIN_WEB_PORT = 1984
|
||||
|
||||
# ── Загрузка ALLOWED_IDS ────────────────────────────────────────────────────
|
||||
@@ -2161,14 +2160,6 @@ async def cb_ssl_status(update: Update, context: ContextTypes.DEFAULT_TYPE) -> N
|
||||
await safe_edit_message(query,text, reply_markup=keyboard, parse_mode="HTML")
|
||||
|
||||
|
||||
def read_admin_web_token() -> str:
|
||||
try:
|
||||
token = Path(ADMIN_WEB_TOKEN_FILE).read_text(encoding="utf-8").strip()
|
||||
return token if len(token) >= 24 else ""
|
||||
except OSError:
|
||||
return ""
|
||||
|
||||
|
||||
async def admin_web_host_hint() -> str:
|
||||
config = load_json(GOTELEGRAM_CONFIG) or {}
|
||||
domain = str(config.get("domain") or "")
|
||||
@@ -2183,18 +2174,15 @@ async def cb_menu_admin_web(update: Update, context: ContextTypes.DEFAULT_TYPE)
|
||||
await query.answer()
|
||||
user_id = _uid(update)
|
||||
running = await check_service_status(ADMIN_WEB_SERVICE)
|
||||
token = read_admin_web_token()
|
||||
host = await admin_web_host_hint()
|
||||
local_url = f"http://127.0.0.1:{ADMIN_WEB_PORT}/?token={token}" if token else f"http://127.0.0.1:{ADMIN_WEB_PORT}/"
|
||||
local_url = f"http://127.0.0.1:{ADMIN_WEB_PORT}/"
|
||||
ssh_cmd = f"ssh -L {ADMIN_WEB_PORT}:127.0.0.1:{ADMIN_WEB_PORT} root@{host}"
|
||||
|
||||
if get_user_lang(user_id) == "ru":
|
||||
status = "запущена" if running else "не запущена"
|
||||
token_note = "Токен найден." if token else "Токен не найден: переустановите/обновите web-admin через CLI."
|
||||
text = (
|
||||
f"<b>🖥 Web Admin</b>\n\n"
|
||||
f"Статус: <code>{status}</code>\n"
|
||||
f"{html.escape(token_note)}\n\n"
|
||||
f"Статус: <code>{status}</code>\n\n"
|
||||
"<b>Termius</b>\n"
|
||||
"1. Откройте сервер → Port Forwarding.\n"
|
||||
f"2. Добавьте Local tunnel: <code>127.0.0.1:{ADMIN_WEB_PORT}</code> → "
|
||||
@@ -2207,11 +2195,9 @@ async def cb_menu_admin_web(update: Update, context: ContextTypes.DEFAULT_TYPE)
|
||||
)
|
||||
else:
|
||||
status = "running" if running else "not running"
|
||||
token_note = "Token is ready." if token else "Token is missing: reinstall/update web-admin from CLI."
|
||||
text = (
|
||||
f"<b>🖥 Web Admin</b>\n\n"
|
||||
f"Status: <code>{status}</code>\n"
|
||||
f"{html.escape(token_note)}\n\n"
|
||||
f"Status: <code>{status}</code>\n\n"
|
||||
"<b>Termius</b>\n"
|
||||
"1. Open the server → Port Forwarding.\n"
|
||||
f"2. Add a Local tunnel: <code>127.0.0.1:{ADMIN_WEB_PORT}</code> → "
|
||||
|
||||
Reference in New Issue
Block a user