mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 10:10:43 +00:00
被控端 - 修复 MTU 问题:夹 MSS + 路径 MTU 探测(公网可用率 48% -> 100%) - 复用 HTTP 连接(免掉每次新建 TLS 的 30% 握手失败) - 每分钟回头找局域网,自动切回快 400 倍的路径 - 画面心跳帧:静止时省流量,客户端仍知道流是活的 - 锁屏时给出可操作的提示 手表端 - 内置 GTS Root R4 / GlobalSign Root CA,修 SSLHandshakeException - 连接错误翻译成人话(证书/时间/解析/超时分别提示) - 经中转连上后用服务器报的地址刷新已配对记录 - 新增局域网连接页面、服务器延迟检测 服务器端 - 支持 chunked 请求体(修每 16 秒一次的连接错乱与大面积 502) - 网络调优脚本 net-tune.sh(开机自动应用) - 管理页:批量删除、网络体检、下载区 - 隧道改 HTTP/2 + 双连接 文档 - 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
76 lines
2.6 KiB
Python
76 lines
2.6 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""防止「源码模式跑修复,把打包版的程序级放行规则冲掉」。
|
||
|
||
真机事故链:
|
||
打包版安装的规则本来是对的(指向 LanRemote-Agent.exe)。
|
||
之后有人从源码模式(sys.executable = python.exe)跑了一次修复,
|
||
于是 App 规则被改写成 python.exe,
|
||
打包版 EXE 从此没有程序级放行 → Windows 又给它建阻止规则 → 又连不上。
|
||
|
||
修法:修复脚本的目标程序改用 target_executable():
|
||
* 打包运行时 -> 就是自己(正确)
|
||
* 源码运行时 -> 如果机器上已有指向某个 EXE 的规则且文件还在,
|
||
就沿用那个目标,不动打包版
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
import ast
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
|
||
FIREWALL = ROOT / "windows" / "lanremote" / "firewall.py"
|
||
|
||
OLD = '''def app_rule_exists() -> bool:'''
|
||
|
||
NEW = '''def target_executable() -> str:
|
||
"""修复脚本应该放行哪个程序。
|
||
|
||
正常情况下就是当前进程自己(打包后 sys.executable 是 EXE)。
|
||
但源码模式下它是 python.exe —— 如果机器上已经有一条指向打包版 EXE
|
||
的程序级放行规则,就沿用那个目标,避免源码模式跑一次修复
|
||
把打包版的规则冲掉(真机上就这么踩过一次)。
|
||
"""
|
||
current = executable_path()
|
||
if getattr(sys, "frozen", False):
|
||
return current
|
||
existing = app_rule_program()
|
||
base = os.path.basename(existing or "").lower()
|
||
if (existing and base.endswith(".exe") and "python" not in base
|
||
and os.path.isfile(existing)):
|
||
return existing
|
||
return current
|
||
|
||
|
||
def app_rule_exists() -> bool:'''
|
||
|
||
OLD_BUILD = ''' exe = executable_path()'''
|
||
NEW_BUILD = ''' exe = target_executable()'''
|
||
|
||
|
||
def main() -> int:
|
||
text = FIREWALL.read_text(encoding="utf-8")
|
||
ok = True
|
||
for old, new, tag in ((OLD, NEW, "target_executable"), (OLD_BUILD, NEW_BUILD, "build_script 目标")):
|
||
if old not in text:
|
||
print(f" [失败] {tag} 锚点未匹配")
|
||
ok = False
|
||
else:
|
||
text = text.replace(old, new, 1)
|
||
|
||
if ok:
|
||
FIREWALL.write_text(text, encoding="utf-8")
|
||
print(" firewall.py: 已加 target_executable(),修复不再冲掉打包版规则")
|
||
|
||
try:
|
||
ast.parse(FIREWALL.read_text(encoding="utf-8"))
|
||
print(" 语法: OK")
|
||
except SyntaxError as exc:
|
||
print(f" 语法错误: {exc}")
|
||
ok = False
|
||
return 0 if ok else 1
|
||
|
||
|
||
if __name__ == "__main__":
|
||
sys.exit(main())
|