host detect in first-run window
This commit is contained in:
parent
968827445f
commit
17e37f9ca0
3
macos.py
3
macos.py
|
|
@ -427,6 +427,7 @@ def _show_first_run() -> None:
|
|||
port = _config.get("port", DEFAULT_CONFIG["port"])
|
||||
secret = _config.get("secret", DEFAULT_CONFIG["secret"])
|
||||
tg_url = tg_proxy_url(_config)
|
||||
link_host = tg_ws_proxy.get_link_host(host)
|
||||
|
||||
text = (
|
||||
f"Прокси запущен и работает в строке меню.\n\n"
|
||||
|
|
@ -436,7 +437,7 @@ def _show_first_run() -> None:
|
|||
f" Или ссылка: {tg_url}\n\n"
|
||||
f"Вручную:\n"
|
||||
f" Настройки → Продвинутые → Тип подключения → Прокси\n"
|
||||
f" MTProto → {host} : {port} \n"
|
||||
f" MTProto → {link_host} : {port} \n"
|
||||
f" Secret: dd{secret} \n\n"
|
||||
f"Открыть прокси в Telegram сейчас?"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1029,15 +1029,7 @@ async def _run(stop_event: Optional[asyncio.Event] = None):
|
|||
except (OSError, AttributeError):
|
||||
pass
|
||||
|
||||
link_host = proxy_config.host
|
||||
if proxy_config.host == '0.0.0.0':
|
||||
try:
|
||||
with _socket.socket(_socket.AF_INET, _socket.SOCK_DGRAM) as _s:
|
||||
_s.connect(('8.8.8.8', 80))
|
||||
link_host = _s.getsockname()[0]
|
||||
except OSError:
|
||||
link_host = '127.0.0.1'
|
||||
|
||||
link_host = get_link_host(proxy_config.host)
|
||||
tg_link = f"tg://proxy?server={link_host}&port={proxy_config.port}&secret=dd{proxy_config.secret}"
|
||||
|
||||
log.info("=" * 60)
|
||||
|
|
|
|||
|
|
@ -445,7 +445,8 @@ def populate_first_run_window(
|
|||
secret: str,
|
||||
on_done: Callable[[bool], None],
|
||||
) -> None:
|
||||
tg_url = f"tg://proxy?server={host}&port={port}&secret=dd{secret}"
|
||||
link_host = tg_ws_proxy.get_link_host(host)
|
||||
tg_url = f"tg://proxy?server={link_host}&port={port}&secret=dd{secret}"
|
||||
fpx, fpy = FIRST_RUN_FRAME_PAD
|
||||
frame = main_content_frame(ctk, root, theme, padx=fpx, pady=fpy)
|
||||
|
||||
|
|
@ -467,7 +468,7 @@ def populate_first_run_window(
|
|||
(f" Или скопировать ссылку, отправить её себе в TG и нажать по ней: {tg_url}", False),
|
||||
("\n Вручную:", True),
|
||||
(" Настройки → Продвинутые → Тип подключения → Прокси", False),
|
||||
(f" MTProto → {host} : {port}", False),
|
||||
(f" MTProto → {link_host} : {port}", False),
|
||||
(f" Secret: dd{secret}", False),
|
||||
]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue