v2.3.1: fix QR top margin, use domain instead of IP for pro-mode links

This commit is contained in:
anten-ka
2026-04-09 00:59:42 +03:00
parent 96cbd243d9
commit a21d2ebea2
3 changed files with 57 additions and 14 deletions

View File

@@ -835,7 +835,7 @@ async def cb_pro_confirm(update: Update, context: ContextTypes.DEFAULT_TYPE) ->
async def get_proxy_link() -> Optional[str]:
"""Generate proxy link from config."""
"""Generate proxy link from config. Pro-mode uses domain + fake-TLS secret."""
config = load_json(GOTELEGRAM_CONFIG)
if not config:
return None
@@ -851,12 +851,20 @@ async def get_proxy_link() -> Optional[str]:
if not secret:
return None
# Get server IP
mode = config.get("mode", "lite")
domain = config.get("domain", "")
port = config.get("port", 443)
# Pro-режим: ссылка с доменом и fake-TLS секретом (ee + secret + hex domain)
if mode == "pro" and domain:
domain_hex = domain.encode().hex()
faketls_secret = f"ee{secret}{domain_hex}"
return f"tg://proxy?server={domain}&port={port}&secret={faketls_secret}"
# Lite-режим: IP
code, stdout, _ = await sh("curl", "-s", "-4", "--max-time", "5", "https://api.ipify.org")
server = stdout.strip() if code == 0 and stdout.strip() else "0.0.0.0"
port = config.get("port", 443)
return f"tg://proxy?server={server}&port={port}&secret={secret}"