mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 13:40:45 +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 + 双连接 文档 - 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
114 lines
4.2 KiB
Python
114 lines
4.2 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""生成指向**正确 exe** 的修复脚本,并自检。
|
||
|
||
真机踩到的坑:程序级放行规则被写成了 python.exe(源码模式的值),
|
||
于是打包后的 ykxmz.exe 依然没有程序级放行,
|
||
系统继续自动生成阻止规则 —— "删了又回来"。
|
||
|
||
这里显式传入 exe 路径,并在生成后核对脚本里确实是这个路径。
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
EXE = r"C:\Users\shu\Desktop\deepseekagent\LanRemote\dist_exe\ykxmz\ykxmz.exe"
|
||
PORTS = (8765, 8766)
|
||
|
||
LINES = [
|
||
"@echo off",
|
||
"chcp 936 >nul",
|
||
"title 局域网遥控 - 修复防火墙(指定 exe)",
|
||
'cd /d "%~dp0"',
|
||
"",
|
||
"net session >nul 2>nul",
|
||
"if not errorlevel 1 goto ELEVATED",
|
||
"echo.",
|
||
"echo 需要管理员权限,正在请求提权,请在弹窗里点「是」...",
|
||
'powershell -NoProfile -Command "Start-Process -FilePath \'%~f0\' -Verb RunAs"',
|
||
"exit /b",
|
||
"",
|
||
":ELEVATED",
|
||
"",
|
||
f'set "EXE={EXE}"',
|
||
"",
|
||
"echo ============================================================",
|
||
"echo 局域网遥控 - 修复防火墙",
|
||
"echo ============================================================",
|
||
"echo.",
|
||
"echo [1/4] 删除所有阻止规则(按程序名)...",
|
||
'netsh advfirewall firewall delete rule name="lanremote-agent.exe" dir=in',
|
||
'netsh advfirewall firewall delete rule name="python.exe" dir=in',
|
||
'netsh advfirewall firewall delete rule name="pythonw.exe" dir=in',
|
||
"echo.",
|
||
"echo [2/4] 删除旧的放行规则 ...",
|
||
'netsh advfirewall firewall delete rule name="LAN Remote TCP"',
|
||
'netsh advfirewall firewall delete rule name="LAN Remote UDP"',
|
||
'netsh advfirewall firewall delete rule name="LAN Remote App TCP"',
|
||
'netsh advfirewall firewall delete rule name="LAN Remote App UDP"',
|
||
"echo.",
|
||
"echo [3/4] 端口放行 ...",
|
||
f'netsh advfirewall firewall add rule name="LAN Remote TCP" '
|
||
f"dir=in action=allow protocol=TCP localport={PORTS[0]} profile=any",
|
||
f'netsh advfirewall firewall add rule name="LAN Remote UDP" '
|
||
f"dir=in action=allow protocol=UDP localport={PORTS[1]} profile=any",
|
||
"echo.",
|
||
"echo [4/4] 程序级放行(指向被控端 exe 本身)...",
|
||
"echo 程序: %EXE%",
|
||
'if not exist "%EXE%" goto NOEXE',
|
||
'netsh advfirewall firewall add rule name="LAN Remote App TCP" '
|
||
'dir=in action=allow program="%EXE%" enable=yes protocol=TCP profile=any',
|
||
'netsh advfirewall firewall add rule name="LAN Remote App UDP" '
|
||
'dir=in action=allow program="%EXE%" enable=yes protocol=UDP profile=any',
|
||
"goto SHOW",
|
||
"",
|
||
":NOEXE",
|
||
"echo [错误] 找不到文件: %EXE%",
|
||
"echo 被控端可能被移动过,请把它放回该路径后重跑本脚本。",
|
||
"goto END",
|
||
"",
|
||
":SHOW",
|
||
"echo.",
|
||
"echo ============================================================",
|
||
"echo 完成!核对下面 Program 一栏是否为本机被控端 exe:",
|
||
"echo ============================================================",
|
||
'netsh advfirewall firewall show rule name="LAN Remote App TCP"',
|
||
"",
|
||
":END",
|
||
"echo.",
|
||
"pause",
|
||
]
|
||
|
||
|
||
def main() -> int:
|
||
target = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\_fix_exe.bat")
|
||
with open(target, "w", encoding="gbk", newline="\r\n") as handle:
|
||
handle.write("\n".join(LINES) + "\n")
|
||
|
||
data = target.read_bytes()
|
||
crlf = data.count(b"\r\n")
|
||
lone = data.count(b"\n") - crlf
|
||
text = data.decode("gbk")
|
||
|
||
print(f" 路径: {target}")
|
||
print(f" 大小: {len(data)} 字节 CRLF={crlf} 裸LF={lone}")
|
||
problems = []
|
||
if lone:
|
||
problems.append("存在裸 LF")
|
||
if 'program="%EXE%"' not in text:
|
||
problems.append("缺少 program=%EXE%")
|
||
if EXE not in text:
|
||
problems.append("EXE 路径未写入")
|
||
if not Path(EXE).is_file():
|
||
problems.append(f"目标 exe 不存在: {EXE}")
|
||
if problems:
|
||
for p in problems:
|
||
print(f" [失败] {p}")
|
||
return 1
|
||
print(" 自检: 通过(路径正确、CRLF 正确、目标文件存在)")
|
||
return 0
|
||
|
||
|
||
if __name__ == "__main__":
|
||
sys.exit(main())
|