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
This commit is contained in:
anten-ka
2026-04-10 00:16:30 +03:00
parent 63b2fc3717
commit 9c084f37ec
3 changed files with 22 additions and 14 deletions

View File

@@ -499,12 +499,15 @@ async def get_status_text() -> str:
if "port" in config: if "port" in config:
lines.append(f"<b>Port:</b> {html.escape(str(config['port']))}") lines.append(f"<b>Port:</b> {html.escape(str(config['port']))}")
# Telemt config # Telemt config (v3: [server] port = ..., [censorship] tls_domain = ...)
telemt_cfg = load_toml(TELEMT_CONFIG) telemt_cfg = load_toml(TELEMT_CONFIG)
if telemt_cfg: if telemt_cfg:
cfg = telemt_cfg.get("config", {}) server_cfg = telemt_cfg.get("server", {})
if "listen_port" in cfg: if "port" in server_cfg:
lines.append(f"<b>Listen Port:</b> {cfg['listen_port']}") lines.append(f"<b>Listen Port:</b> {server_cfg['port']}")
censor_cfg = telemt_cfg.get("censorship", {})
if "tls_domain" in censor_cfg:
lines.append(f"<b>TLS Domain:</b> {html.escape(str(censor_cfg['tls_domain']))}")
# Backups # Backups
backup_count = 0 backup_count = 0
@@ -946,14 +949,15 @@ async def get_proxy_link() -> Optional[str]:
if not config: if not config:
return None return None
# Get secret from telemt TOML config # Get secret from telemt TOML config (v3 format: [access.users] main = "...")
secret = config.get("secret", "") secret = config.get("secret", "")
if not secret: if not secret:
telemt_cfg = load_toml(TELEMT_CONFIG) telemt_cfg = load_toml(TELEMT_CONFIG)
if telemt_cfg: if telemt_cfg:
users = telemt_cfg.get("users", []) access = telemt_cfg.get("access", {})
if isinstance(users, list) and users: users = access.get("users", {})
secret = users[0].get("secret", "") if isinstance(users, dict):
secret = users.get("main", "")
if not secret: if not secret:
return None return None

View File

@@ -262,7 +262,7 @@ menu_install() {
echo -e " ${CYAN}2)${NC} ${MAGENTA}🛡 Pro${NC} — свой сайт + полная маскировка" echo -e " ${CYAN}2)${NC} ${MAGENTA}🛡 Pro${NC} — свой сайт + полная маскировка"
echo -e " ${DIM}nginx + SSL + HTML-шаблон + telemt.${NC}" echo -e " ${DIM}nginx + SSL + HTML-шаблон + telemt.${NC}"
echo -e " ${DIM}DPI видит реальный сайт с реальным сертификатом.${NC}" echo -e " ${DIM}DPI видит реальный сайт с реальным сертификатом.${NC}"
echo -e " ${DIM}Требует: домен, направленный на этот сервер.{{NC}" echo -e " ${DIM}Требует: домен, направленный на этот сервер.${NC}"
echo -e " ${DIM}$(printf '─%.0s' {1..55})${NC}" echo -e " ${DIM}$(printf '─%.0s' {1..55})${NC}"
echo -ne " ${WHITE}Выбор (1/2):${NC} " echo -ne " ${WHITE}Выбор (1/2):${NC} "
read -r mode_choice read -r mode_choice

View File

@@ -81,13 +81,17 @@ add_secret_to_config() {
return 1 return 1
fi fi
# Добавляем новый блок [[users]] # telemt v3: добавляем ключ в секцию [access.users]
cat >> "$config" << EOSECRET # Формат: name = "secret" под блоком [access.users]
if grep -q '\[access\.users\]' "$config"; then
sed -i "/\[access\.users\]/a ${name} = \"${secret}\"" "$config"
else
cat >> "$config" << EOSECRET
[[users]] [access.users]
name = "${name}" ${name} = "${secret}"
secret = "${secret}"
EOSECRET EOSECRET
fi
log_success "Добавлен секрет: $name" log_success "Добавлен секрет: $name"
} }