mirror of
https://github.com/Flowseal/tg-ws-proxy.git
synced 2026-05-17 00:25:51 +03:00
update imports after refactor
This commit is contained in:
4
linux.py
4
linux.py
@@ -12,7 +12,7 @@ import pyperclip
|
||||
import pystray
|
||||
from PIL import Image, ImageTk
|
||||
|
||||
import proxy.tg_ws_proxy as tg_ws_proxy
|
||||
from proxy import get_link_host
|
||||
|
||||
from utils.tray_common import (
|
||||
APP_NAME, DEFAULT_CONFIG, FIRST_RUN_MARKER, LOG_FILE,
|
||||
@@ -227,7 +227,7 @@ def _show_first_run() -> None:
|
||||
def _build_menu():
|
||||
host = _config.get("host", DEFAULT_CONFIG["host"])
|
||||
port = _config.get("port", DEFAULT_CONFIG["port"])
|
||||
link_host = tg_ws_proxy.get_link_host(host)
|
||||
link_host = get_link_host(host)
|
||||
return pystray.Menu(
|
||||
pystray.MenuItem(f"Открыть в Telegram ({link_host}:{port})", _on_open_in_telegram, default=True),
|
||||
pystray.MenuItem("Скопировать ссылку", _on_copy_link),
|
||||
|
||||
16
macos.py
16
macos.py
@@ -24,8 +24,8 @@ try:
|
||||
except ImportError:
|
||||
pyperclip = None
|
||||
|
||||
import proxy.tg_ws_proxy as tg_ws_proxy
|
||||
from proxy import __version__
|
||||
from proxy import __version__, get_link_host, parse_dc_ip_list, proxy_config
|
||||
from proxy.tg_ws_proxy import _run
|
||||
|
||||
from utils.tray_common import (
|
||||
APP_DIR, APP_NAME, DEFAULT_CONFIG, FIRST_RUN_MARKER, IPV6_WARN_MARKER,
|
||||
@@ -153,7 +153,7 @@ def _run_proxy_thread() -> None:
|
||||
stop_ev = _asyncio.Event()
|
||||
_async_stop = (loop, stop_ev)
|
||||
try:
|
||||
loop.run_until_complete(tg_ws_proxy._run(stop_event=stop_ev))
|
||||
loop.run_until_complete(_run(stop_event=stop_ev))
|
||||
except Exception as exc:
|
||||
log.error("Proxy thread crashed: %s", exc)
|
||||
if "Address already in use" in str(exc):
|
||||
@@ -176,7 +176,7 @@ def _start_proxy() -> None:
|
||||
if not apply_proxy_config(_config):
|
||||
_show_error("Ошибка конфигурации DC → IP.")
|
||||
return
|
||||
pc = tg_ws_proxy.proxy_config
|
||||
pc = proxy_config
|
||||
log.info("Starting proxy on %s:%d ...", pc.host, pc.port)
|
||||
_proxy_thread = threading.Thread(target=_run_proxy_thread, daemon=True, name="proxy")
|
||||
_proxy_thread.start()
|
||||
@@ -362,7 +362,7 @@ def _edit_config_dialog() -> None:
|
||||
return
|
||||
dc_lines = [s.strip() for s in dc_str.replace(",", "\n").splitlines() if s.strip()]
|
||||
try:
|
||||
tg_ws_proxy.parse_dc_ip_list(dc_lines)
|
||||
parse_dc_ip_list(dc_lines)
|
||||
except ValueError as e:
|
||||
_show_error(str(e))
|
||||
return
|
||||
@@ -451,7 +451,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)
|
||||
link_host = get_link_host(host)
|
||||
|
||||
text = (
|
||||
f"Прокси запущен и работает в строке меню.\n\n"
|
||||
@@ -520,7 +520,7 @@ class TgWsProxyApp(_TgWsProxyAppBase):
|
||||
|
||||
host = _config.get("host", DEFAULT_CONFIG["host"])
|
||||
port = _config.get("port", DEFAULT_CONFIG["port"])
|
||||
link_host = tg_ws_proxy.get_link_host(host)
|
||||
link_host = get_link_host(host)
|
||||
|
||||
self._open_tg_item = rumps.MenuItem(
|
||||
f"Открыть в Telegram ({link_host}:{port})", callback=_on_open_in_telegram
|
||||
@@ -560,7 +560,7 @@ class TgWsProxyApp(_TgWsProxyAppBase):
|
||||
def update_menu_title(self) -> None:
|
||||
host = _config.get("host", DEFAULT_CONFIG["host"])
|
||||
port = _config.get("port", DEFAULT_CONFIG["port"])
|
||||
link_host = tg_ws_proxy.get_link_host(host)
|
||||
link_host = get_link_host(host)
|
||||
self._open_tg_item.title = f"Открыть в Telegram ({link_host}:{port})"
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@ import webbrowser
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
||||
|
||||
import proxy.tg_ws_proxy as tg_ws_proxy
|
||||
from proxy import __version__
|
||||
from proxy import __version__, get_link_host, parse_dc_ip_list
|
||||
from utils.update_check import RELEASES_PAGE_URL, get_status
|
||||
|
||||
from ui.ctk_theme import (
|
||||
@@ -536,7 +535,7 @@ def validate_config_form(
|
||||
if line.strip()
|
||||
]
|
||||
try:
|
||||
tg_ws_proxy.parse_dc_ip_list(lines)
|
||||
parse_dc_ip_list(lines)
|
||||
except ValueError as e:
|
||||
return str(e)
|
||||
|
||||
@@ -621,7 +620,7 @@ def populate_first_run_window(
|
||||
secret: str,
|
||||
on_done: Callable[[bool], None],
|
||||
) -> None:
|
||||
link_host = tg_ws_proxy.get_link_host(host)
|
||||
link_host = 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)
|
||||
|
||||
@@ -14,8 +14,8 @@ from typing import Any, Callable, Dict, Optional, Tuple
|
||||
|
||||
import psutil
|
||||
|
||||
import proxy.tg_ws_proxy as tg_ws_proxy
|
||||
from proxy import __version__
|
||||
from proxy import __version__, get_link_host, parse_dc_ip_list, proxy_config
|
||||
from proxy.tg_ws_proxy import _run
|
||||
from utils.default_config import default_tray_config
|
||||
|
||||
log = logging.getLogger("tg-ws-tray")
|
||||
@@ -239,7 +239,7 @@ def _run_proxy_thread(on_port_busy: Callable[[str], None]) -> None:
|
||||
_async_stop = (loop, stop_ev)
|
||||
|
||||
try:
|
||||
loop.run_until_complete(tg_ws_proxy._run(stop_event=stop_ev))
|
||||
loop.run_until_complete(_run(stop_event=stop_ev))
|
||||
except Exception as exc:
|
||||
log.error("Proxy thread crashed: %s", exc)
|
||||
if "Address already in use" in str(exc) or "10048" in str(exc):
|
||||
@@ -257,12 +257,12 @@ def _run_proxy_thread(on_port_busy: Callable[[str], None]) -> None:
|
||||
def apply_proxy_config(cfg: dict) -> bool:
|
||||
dc_ip_list = cfg.get("dc_ip", DEFAULT_CONFIG["dc_ip"])
|
||||
try:
|
||||
dc_redirects = tg_ws_proxy.parse_dc_ip_list(dc_ip_list)
|
||||
dc_redirects = parse_dc_ip_list(dc_ip_list)
|
||||
except ValueError as e:
|
||||
log.error("Bad config dc_ip: %s", e)
|
||||
return False
|
||||
|
||||
pc = tg_ws_proxy.proxy_config
|
||||
pc = proxy_config
|
||||
pc.port = cfg.get("port", DEFAULT_CONFIG["port"])
|
||||
pc.host = cfg.get("host", DEFAULT_CONFIG["host"])
|
||||
pc.secret = cfg.get("secret", DEFAULT_CONFIG["secret"])
|
||||
@@ -285,7 +285,7 @@ def start_proxy(cfg: dict, on_error: Callable[[str], None]) -> None:
|
||||
on_error("Ошибка конфигурации DC → IP.")
|
||||
return
|
||||
|
||||
pc = tg_ws_proxy.proxy_config
|
||||
pc = proxy_config
|
||||
log.info("Starting proxy on %s:%d ...", pc.host, pc.port)
|
||||
_proxy_thread = threading.Thread(
|
||||
target=_run_proxy_thread, args=(on_error,), daemon=True, name="proxy"
|
||||
@@ -315,7 +315,7 @@ def tg_proxy_url(cfg: dict) -> str:
|
||||
host = cfg.get("host", DEFAULT_CONFIG["host"])
|
||||
port = cfg.get("port", DEFAULT_CONFIG["port"])
|
||||
secret = cfg.get("secret", DEFAULT_CONFIG["secret"])
|
||||
link_host = tg_ws_proxy.get_link_host(host)
|
||||
link_host = get_link_host(host)
|
||||
return f"tg://proxy?server={link_host}&port={port}&secret=dd{secret}"
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ try:
|
||||
except ImportError:
|
||||
Image = None
|
||||
|
||||
import proxy.tg_ws_proxy as tg_ws_proxy
|
||||
from proxy import get_link_host
|
||||
|
||||
from utils.win32_theme import (
|
||||
is_windows_dark_theme,
|
||||
@@ -301,7 +301,7 @@ def _build_menu():
|
||||
return None
|
||||
host = _config.get("host", DEFAULT_CONFIG["host"])
|
||||
port = _config.get("port", DEFAULT_CONFIG["port"])
|
||||
link_host = tg_ws_proxy.get_link_host(host)
|
||||
link_host = get_link_host(host)
|
||||
return pystray.Menu(
|
||||
pystray.MenuItem(f"Открыть в Telegram ({link_host}:{port})", _on_open_in_telegram, default=True),
|
||||
pystray.MenuItem("Скопировать ссылку", _on_copy_link),
|
||||
|
||||
Reference in New Issue
Block a user