mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 21:50:44 +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 + 鍙岃繛鎺? 鏂囨。 - 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
159 lines
5.3 KiB
Python
159 lines
5.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""测改名和卸载。
|
|
|
|
小心的事:
|
|
uninstall 会删数据目录 —— 测试时**必须**把它指到临时目录,
|
|
否则会把用户真正的配对码清掉。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
sys.path.insert(0, str(ROOT / "windows"))
|
|
|
|
passed = 0
|
|
failed = 0
|
|
|
|
|
|
def check(name, ok, detail=""):
|
|
global passed, failed
|
|
if ok:
|
|
passed += 1
|
|
print(" [PASS] " + name)
|
|
else:
|
|
failed += 1
|
|
print(" [FAIL] " + name + " " + str(detail))
|
|
|
|
|
|
def reg_query(name: str) -> str:
|
|
proc = subprocess.run(
|
|
["reg", "query", r"HKCU\Software\Microsoft\Windows\CurrentVersion\Run",
|
|
"/v", name],
|
|
capture_output=True, text=True, encoding="mbcs", errors="replace")
|
|
return proc.stdout if proc.returncode == 0 else ""
|
|
|
|
|
|
def main() -> int:
|
|
from lanremote import autostart
|
|
|
|
print("一、名字改对了吗")
|
|
check("自启项名是 ykxmz", autostart.VALUE_NAME == "ykxmz",
|
|
autostart.VALUE_NAME)
|
|
check("记得要清理的旧名", autostart.LEGACY_VALUE_NAMES
|
|
== ("LanRemoteAgent",), autostart.LEGACY_VALUE_NAMES)
|
|
|
|
print()
|
|
print("二、真的写进注册表看看(测完会删掉)")
|
|
had_before = autostart.is_enabled()
|
|
if had_before:
|
|
print(" (本来就有自启项,测试时会先记下来,最后恢复)")
|
|
original = autostart.current_value()
|
|
|
|
try:
|
|
message = autostart.enable()
|
|
check("enable 成功了", "已开启" in message, message[:80])
|
|
|
|
# 注册表里确实有 ykxmz
|
|
out = reg_query("ykxmz")
|
|
check("注册表里有 ykxmz 这一项", "ykxmz" in out, out[:100])
|
|
check("它指向真实存在的程序",
|
|
"--silent" in out or ".exe" in out, out[:120])
|
|
|
|
# 任务管理器的启动项列表(StartupApproved)里能看到
|
|
proc = subprocess.run(
|
|
["reg", "query",
|
|
r"HKCU\Software\Microsoft\Windows\CurrentVersion"
|
|
r"\Explorer\StartupApproved\Run"],
|
|
capture_output=True, text=True, encoding="mbcs",
|
|
errors="replace")
|
|
# 没写过 StartupApproved 也算正常(说明没被禁用过);
|
|
# 关键是 Run 里有,任务管理器就会列出来。
|
|
check("Run 项存在(任务管理器就会显示)", "ykxmz" in reg_query("ykxmz"))
|
|
|
|
# 旧名要清掉
|
|
check("旧名 LanRemoteAgent 不在注册表里",
|
|
"LanRemoteAgent" not in reg_query("LanRemoteAgent"))
|
|
|
|
print()
|
|
print("三、关闭要能删掉")
|
|
autostart.disable()
|
|
check("disable 之后 is_enabled 变 False",
|
|
not autostart.is_enabled())
|
|
check("注册表里查不到了", reg_query("ykxmz") == "")
|
|
|
|
finally:
|
|
# 恢复原状
|
|
if had_before:
|
|
subprocess.run(
|
|
["reg", "add",
|
|
r"HKCU\Software\Microsoft\Windows\CurrentVersion\Run",
|
|
"/v", "ykxmz", "/t", "REG_SZ", "/d", original, "/f"],
|
|
capture_output=True)
|
|
print(" (已恢复原来那条自启项)")
|
|
else:
|
|
autostart.disable()
|
|
|
|
print()
|
|
print("四、卸载逻辑(数据目录指到临时目录,不动你的真数据)")
|
|
from lanremote import uninstall
|
|
|
|
work = Path(tempfile.mkdtemp(prefix="uninstall_test_"))
|
|
try:
|
|
# 造假的数据目录,并把它指过去
|
|
fake_data = work / "data"
|
|
fake_data.mkdir(parents=True, exist_ok=True)
|
|
(fake_data / "config.json").write_text(
|
|
json.dumps({"pairing_code": "123456"}), encoding="utf-8")
|
|
|
|
original_data_dir = uninstall.data_dir
|
|
uninstall.data_dir = lambda: str(fake_data)
|
|
|
|
result = uninstall._remove_data()
|
|
check("删数据目录成功", "已删除" in result, result)
|
|
check("数据目录真的没了", not fake_data.exists())
|
|
|
|
uninstall.data_dir = original_data_dir
|
|
|
|
# 自启项清理
|
|
result = uninstall._remove_autostart()
|
|
check("清理自启项不报错", isinstance(result, str) and result, result)
|
|
|
|
# 源码模式下不该真去删自己
|
|
result = uninstall._schedule_self_delete()
|
|
check("源码模式不安排自删", "源码模式" in result, result)
|
|
|
|
finally:
|
|
shutil.rmtree(work, ignore_errors=True)
|
|
|
|
print()
|
|
print("五、源码模式下 --uninstall 不会真的删程序")
|
|
from lanremote.uninstall import run as do_uninstall
|
|
original_data_dir = uninstall.data_dir
|
|
work2 = Path(tempfile.mkdtemp(prefix="uninstall_test2_"))
|
|
try:
|
|
fake2 = work2 / "data"
|
|
fake2.mkdir(parents=True, exist_ok=True)
|
|
uninstall.data_dir = lambda: str(fake2)
|
|
text = do_uninstall()
|
|
check("返回了说明", "卸载完成" in text, text[:80])
|
|
check("说明了不会删源码", "源码模式" in text, text[:200])
|
|
check("真的删了数据目录(临时那个)", not fake2.exists())
|
|
finally:
|
|
uninstall.data_dir = original_data_dir
|
|
shutil.rmtree(work2, ignore_errors=True)
|
|
|
|
print()
|
|
print("=" * 62)
|
|
print(f"通过 {passed} 项,失败 {failed} 项")
|
|
return 0 if failed == 0 else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|