mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 20:40:43 +00:00
琚帶绔?- 淇 MTU 闂锛氬す MSS + 璺緞 MTU 鎺㈡祴锛堝叕缃戝彲鐢ㄧ巼 48% -> 100%锛?- 澶嶇敤 HTTP 杩炴帴锛堝厤鎺夋瘡娆℃柊寤?TLS 鐨?30% 鎻℃墜澶辫触锛?- 姣忓垎閽熷洖澶存壘灞€鍩熺綉锛岃嚜鍔ㄥ垏鍥炲揩 400 鍊嶇殑璺緞 - 鐢婚潰蹇冭烦甯э細闈欐鏃剁渷娴侀噺锛屽鎴风浠嶇煡閬撴祦鏄椿鐨?- 閿佸睆鏃剁粰鍑哄彲鎿嶄綔鐨勬彁绀? 鎵嬭〃绔?- 鍐呯疆 GTS Root R4 / GlobalSign Root CA锛屼慨 SSLHandshakeException - 杩炴帴閿欒缈昏瘧鎴愪汉璇濓紙璇佷功/鏃堕棿/瑙f瀽/瓒呮椂鍒嗗埆鎻愮ず锛?- 缁忎腑杞繛涓婂悗鐢ㄦ湇鍔″櫒鎶ョ殑鍦板潃鍒锋柊宸查厤瀵硅褰?- 鏂板灞€鍩熺綉杩炴帴椤甸潰銆佹湇鍔″櫒寤惰繜妫€娴? 鏈嶅姟鍣ㄧ - 鏀寔 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())
|