mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 13:40:45 +00:00
ykxmz 1.5.0:修复手表端 TLS 证书校验 + MTU 修复网络稳定性
被控端 - 修复 MTU 问题:夹 MSS + 路径 MTU 探测(公网可用率 48% -> 100%) - 复用 HTTP 连接(免掉每次新建 TLS 的 30% 握手失败) - 每分钟回头找局域网,自动切回快 400 倍的路径 - 画面心跳帧:静止时省流量,客户端仍知道流是活的 - 锁屏时给出可操作的提示 手表端 - 内置 GTS Root R4 / GlobalSign Root CA,修 SSLHandshakeException - 连接错误翻译成人话(证书/时间/解析/超时分别提示) - 经中转连上后用服务器报的地址刷新已配对记录 - 新增局域网连接页面、服务器延迟检测 服务器端 - 支持 chunked 请求体(修每 16 秒一次的连接错乱与大面积 502) - 网络调优脚本 net-tune.sh(开机自动应用) - 管理页:批量删除、网络体检、下载区 - 隧道改 HTTP/2 + 双连接 文档 - 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""server.py:收到手表的「请打开网络自检」UDP 请求时,弹出网络自检窗口。"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
SERVER = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\windows"
|
||||
r"\lanremote\server.py")
|
||||
|
||||
OLD = ''' # 启动局域网自动发现,让手表不用输 IP
|
||||
self._discovery = DiscoveryResponder(self.store, self.port)
|
||||
if self._discovery.start():'''
|
||||
|
||||
NEW = ''' # 启动局域网自动发现,让手表不用输 IP
|
||||
self._discovery = DiscoveryResponder(self.store, self.port)
|
||||
# 手表点「连不上?」会广播请求,这里就把网络自检窗口弹出来
|
||||
self._discovery.on_selfcheck = self._on_selfcheck_request
|
||||
if self._discovery.start():'''
|
||||
|
||||
OLD_METHOD = ''' def stop(self) -> None:
|
||||
self._running = False'''
|
||||
|
||||
NEW_METHOD = ''' def _on_selfcheck_request(self, from_ip: str) -> None:
|
||||
"""手表说「我连不上」,就在电脑上把网络自检打开。
|
||||
|
||||
走 UDP 是有意的:连不上的典型原因就是 TCP 被防火墙拦了,
|
||||
而 UDP 广播往往还通(那正是"能搜到但连不上"的原因)。
|
||||
"""
|
||||
self._log(f"[自检] 收到来自 {from_ip} 的请求,正在打开网络自检")
|
||||
|
||||
def launch() -> None:
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from .config import app_dir
|
||||
bat = app_dir() / "网络自检.bat"
|
||||
if not bat.is_file():
|
||||
self._log("[自检] 没找到 网络自检.bat,跳过")
|
||||
return
|
||||
try:
|
||||
flags = getattr(subprocess, "CREATE_NEW_CONSOLE", 0)
|
||||
subprocess.Popen(["cmd", "/c", str(bat)],
|
||||
creationflags=flags,
|
||||
cwd=str(app_dir()))
|
||||
except Exception as exc: # noqa: BLE001
|
||||
self._log(f"[自检] 启动失败:{exc}")
|
||||
|
||||
# 弹窗口这件事要放到主线程做,避免和界面的消息循环打架
|
||||
target = getattr(self, "ui", None)
|
||||
if target is not None and hasattr(target, "ui_call"):
|
||||
try:
|
||||
target.ui_call(launch, timeout=3.0)
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
import threading
|
||||
threading.Thread(target=launch, name="selfcheck", daemon=True).start()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def stop(self) -> None:
|
||||
self._running = False'''
|
||||
|
||||
OLD_STOP = ''' if self._discovery is not None:
|
||||
self._discovery.stop()
|
||||
self._discovery = None'''
|
||||
NEW_STOP = ''' if self._discovery is not None:
|
||||
self._discovery.on_selfcheck = None
|
||||
self._discovery.stop()
|
||||
self._discovery = None'''
|
||||
|
||||
|
||||
def main() -> int:
|
||||
text = SERVER.read_text(encoding="utf-8")
|
||||
ok = True
|
||||
for old, new, tag in ((OLD, NEW, "挂载回调"),
|
||||
(OLD_METHOD, NEW_METHOD, "实现回调"),
|
||||
(OLD_STOP, NEW_STOP, "停止时解绑")):
|
||||
if old not in text:
|
||||
print(f" [失败] {tag} 锚点未匹配")
|
||||
ok = False
|
||||
else:
|
||||
text = text.replace(old, new, 1)
|
||||
print(f" {tag}: OK")
|
||||
|
||||
if ok:
|
||||
SERVER.write_text(text, encoding="utf-8")
|
||||
|
||||
print("\n语法检查:")
|
||||
import ast
|
||||
try:
|
||||
ast.parse(SERVER.read_text(encoding="utf-8"))
|
||||
print(" server.py: OK")
|
||||
except SyntaxError as exc:
|
||||
print(f" server.py: 语法错误 {exc}")
|
||||
ok = False
|
||||
return 0 if ok else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user