From 9c084f37ec56b3da1520528811afc559743ea29f Mon Sep 17 00:00:00 2001 From: anten-ka Date: Fri, 10 Apr 2026 00:16:30 +0300 Subject: [PATCH] bugfix: {{NC}} typo, bot TOML v3 parsing, add_secret v3 format - install.sh: fix {{NC}} -> ${NC} color escape on line 265 - bot.py: fix TOML parsing for telemt v3 [access.users] format - bot.py: fix telemt config section [server].port instead of [config].listen_port - telemt_config.sh: fix add_secret_to_config() for v3 format --- gotelegram-bot/bot.py | 20 ++++++++++++-------- install.sh | 2 +- lib/telemt_config.sh | 14 +++++++++----- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/gotelegram-bot/bot.py b/gotelegram-bot/bot.py index 49a57fc..4e73940 100644 --- a/gotelegram-bot/bot.py +++ b/gotelegram-bot/bot.py @@ -499,12 +499,15 @@ async def get_status_text() -> str: if "port" in config: lines.append(f"Port: {html.escape(str(config['port']))}") - # Telemt config + # Telemt config (v3: [server] port = ..., [censorship] tls_domain = ...) telemt_cfg = load_toml(TELEMT_CONFIG) if telemt_cfg: - cfg = telemt_cfg.get("config", {}) - if "listen_port" in cfg: - lines.append(f"Listen Port: {cfg['listen_port']}") + server_cfg = telemt_cfg.get("server", {}) + if "port" in server_cfg: + lines.append(f"Listen Port: {server_cfg['port']}") + censor_cfg = telemt_cfg.get("censorship", {}) + if "tls_domain" in censor_cfg: + lines.append(f"TLS Domain: {html.escape(str(censor_cfg['tls_domain']))}") # Backups backup_count = 0 @@ -946,14 +949,15 @@ async def get_proxy_link() -> Optional[str]: if not config: return None - # Get secret from telemt TOML config + # Get secret from telemt TOML config (v3 format: [access.users] main = "...") secret = config.get("secret", "") if not secret: telemt_cfg = load_toml(TELEMT_CONFIG) if telemt_cfg: - users = telemt_cfg.get("users", []) - if isinstance(users, list) and users: - secret = users[0].get("secret", "") + access = telemt_cfg.get("access", {}) + users = access.get("users", {}) + if isinstance(users, dict): + secret = users.get("main", "") if not secret: return None diff --git a/install.sh b/install.sh index bff3707..33a54c0 100755 --- a/install.sh +++ b/install.sh @@ -262,7 +262,7 @@ menu_install() { echo -e " ${CYAN}2)${NC} ${MAGENTA}🛡 Pro${NC} — свой сайт + полная маскировка" echo -e " ${DIM}nginx + SSL + HTML-шаблон + telemt.${NC}" echo -e " ${DIM}DPI видит реальный сайт с реальным сертификатом.${NC}" - echo -e " ${DIM}Требует: домен, направленный на этот сервер.{{NC}" + echo -e " ${DIM}Требует: домен, направленный на этот сервер.${NC}" echo -e " ${DIM}$(printf '─%.0s' {1..55})${NC}" echo -ne " ${WHITE}Выбор (1/2):${NC} " read -r mode_choice diff --git a/lib/telemt_config.sh b/lib/telemt_config.sh index 1a4dd2e..01d3482 100755 --- a/lib/telemt_config.sh +++ b/lib/telemt_config.sh @@ -81,13 +81,17 @@ add_secret_to_config() { return 1 fi - # Добавляем новый блок [[users]] - cat >> "$config" << EOSECRET + # telemt v3: добавляем ключ в секцию [access.users] + # Формат: name = "secret" под блоком [access.users] + if grep -q '\[access\.users\]' "$config"; then + sed -i "/\[access\.users\]/a ${name} = \"${secret}\"" "$config" + else + cat >> "$config" << EOSECRET -[[users]] - name = "${name}" - secret = "${secret}" +[access.users] +${name} = "${secret}" EOSECRET + fi log_success "Добавлен секрет: $name" }