Files
ykxmz/_build/fix_rename_leftovers.py
T
xmz7891 b705216e4a ykxmz 1.5.0锛氫慨澶嶆墜琛ㄧ TLS 璇佷功鏍¢獙 + MTU 淇缃戠粶绋冲畾鎬?
琚帶绔?- 淇 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 + 鍙岃繛鎺?
鏂囨。
- 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
2026-10-06 19:01:05 +08:00

119 lines
4.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""改名收尾:防火墙规则名 + verify_all 路径。
1. firewall.py 的 PROGRAM_RULE_NAMES
这是"修复防火墙时要删掉哪些旧规则"的清单。
新程序叫 ykxmz.exe,所以得加进去;
旧的 lanremote-agent.exe 也**保留** —— 老用户升级上来时,
那条旧规则还躺在他机器上,不清掉会两条打架。
2. _tests/verify_all.ps1 还指向 dist_exe\\LanRemote-Agent
3. 测试里的期望值跟着改
"""
from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
FIREWALL = ROOT / "windows" / "lanremote" / "firewall.py"
VERIFY = ROOT / "_tests" / "verify_all.ps1"
FW_TEST = ROOT / "_tests" / "test_firewall.py"
# ---------- 1. firewall.py ----------
RULE_OLD = '''PROGRAM_RULE_NAMES = ("lanremote-agent.exe", "python.exe", "pythonw.exe")'''
RULE_NEW = '''# 修复防火墙时要清掉的旧规则名。
# ykxmz.exe 是现在的名字;lanremote-agent.exe 是改名前的老名字 ——
# 保留它,好让老用户升级上来时把旧规则清掉,不然会两条打架。
PROGRAM_RULE_NAMES = ("ykxmz.exe", "lanremote-agent.exe",
"python.exe", "pythonw.exe")'''
# ---------- 2. verify_all.ps1(注意 BOM)----------
VERIFY_OLD = '''$exe = Join-Path $root "dist_exe\\LanRemote-Agent\\LanRemote-Agent.exe"'''
VERIFY_NEW = '''$exe = Join-Path $root "dist_exe\\ykxmz\\ykxmz.exe"'''
VERIFY_PROC_OLD = '''Get-Process LanRemote-Agent -ErrorAction SilentlyContinue |'''
VERIFY_PROC_NEW = '''Get-Process ykxmz -ErrorAction SilentlyContinue |'''
# ---------- 3. 测试期望值 ----------
TEST_RULES = [
('names == {"lanremote-agent.exe"}, str(names))',
'names == {"ykxmz.exe"}, str(names))'),
('check("脚本删除了 lanremote-agent.exe 的规则",\n'
' \'delete rule name="lanremote-agent.exe" dir=in\' in script)',
'check("脚本删除了 ykxmz.exe 的规则",\n'
' \'delete rule name="ykxmz.exe" dir=in\' in script)'),
('zh.get("RuleName") == "lanremote-agent.exe", str(zh.get("RuleName")))',
'zh.get("RuleName") == "ykxmz.exe", str(zh.get("RuleName")))'),
('(zh.get("Program") or "").lower().endswith("lanremote-agent.exe"),',
'(zh.get("Program") or "").lower().endswith("ykxmz.exe"),'),
('en.get("RuleName") == "lanremote-agent.exe", str(en.get("RuleName")))',
'en.get("RuleName") == "ykxmz.exe", str(en.get("RuleName")))'),
]
def main() -> int:
ok = True
# firewall.py
text = FIREWALL.read_text(encoding="utf-8")
if "ykxmz.exe" in text:
print(" firewall.py: 已经改过")
elif RULE_OLD in text:
text = text.replace(RULE_OLD, RULE_NEW, 1)
FIREWALL.write_text(text, encoding="utf-8", newline="\n")
print(" firewall.py: PROGRAM_RULE_NAMES 加上 ykxmz.exe")
else:
print(" [失败] firewall.py 锚点没找到")
ok = False
# verify_all.ps1(保持 BOM)
raw = VERIFY.read_bytes()
had_bom = raw.startswith(b"\xef\xbb\xbf")
text = raw.decode("utf-8-sig")
changed = 0
if VERIFY_OLD in text:
text = text.replace(VERIFY_OLD, VERIFY_NEW, 1)
changed += 1
if VERIFY_PROC_OLD in text:
text = text.replace(VERIFY_PROC_OLD, VERIFY_PROC_NEW, 1)
changed += 1
if changed:
body = text.replace("\r\n", "\n").encode("utf-8")
VERIFY.write_bytes((b"\xef\xbb\xbf" if had_bom else b"") + body)
print(f" verify_all.ps1: 改了 {changed} 处(BOM {'保留' if had_bom else '无'})")
else:
print(" verify_all.ps1: 没变化")
# 测试期望值
text = FW_TEST.read_text(encoding="utf-8")
changed = 0
for old, new in TEST_RULES:
if old in text:
text = text.replace(old, new)
changed += 1
if changed:
FW_TEST.write_text(text, encoding="utf-8", newline="\n")
print(f" 测试期望值: 改了 {changed} 处")
else:
print(" 测试期望值: 没变化")
# 语法
import ast
for label, path in (("firewall.py", FIREWALL), ("test_firewall.py", FW_TEST)):
try:
ast.parse(path.read_text(encoding="utf-8"))
print(f" {label} 语法 OK")
except SyntaxError as exc:
print(f" {label} 语法错误: {exc}")
ok = False
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())