mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 20:40:43 +00:00
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 + 鍙岃繛鎺? 鏂囨。 - 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""验证回退(撤销)系统。
|
||||
|
||||
要点:
|
||||
* 可回退的操作执行后会自动进回退列表
|
||||
* 回退能把状态真的改回去
|
||||
* **不可回退的操作(关机、删文件、杀进程)不该被记录** ——
|
||||
记了会给用户"还能退回去"的错觉,反而危险
|
||||
"""
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT / "windows"))
|
||||
|
||||
from lanremote.actions import Actions # noqa: E402
|
||||
from lanremote.config import Store # noqa: E402
|
||||
from lanremote.features import Features # noqa: E402
|
||||
from lanremote.headless import HeadlessUI # noqa: E402
|
||||
|
||||
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 main() -> int:
|
||||
store = Store(Path(tempfile.mkdtemp()))
|
||||
ui = HeadlessUI(store)
|
||||
features = Features(Actions(ui, store))
|
||||
ui.root
|
||||
|
||||
print("一、三个回退功能都在")
|
||||
defs = features.defs()
|
||||
names = {d["name"] for d in defs}
|
||||
for required in ("undo_last", "undo_all", "undo_list"):
|
||||
check("声明了 " + required, required in names)
|
||||
check("功能总数 > 200", len(defs) > 200, len(defs))
|
||||
|
||||
print()
|
||||
print("二、初始没有可回退的")
|
||||
check("undo_list 说没有",
|
||||
"没有" in features.run("undo_list", {}),
|
||||
features.run("undo_list", {}))
|
||||
check("undo_last 说没有",
|
||||
"没有" in features.run("undo_last", {}),
|
||||
features.run("undo_last", {}))
|
||||
|
||||
print()
|
||||
print("三、做几个可回退的操作")
|
||||
features.run("shuffle_play", {"on": True})
|
||||
check("开关被记为可回退", len(features._undo_stack()) == 1,
|
||||
len(features._undo_stack()))
|
||||
features.run("loop_play", {"on": True})
|
||||
features.run("big_text", {"text": "回退测试"})
|
||||
check("三步都记上了", len(features._undo_stack()) == 3,
|
||||
len(features._undo_stack()))
|
||||
|
||||
listing = features.run("undo_list", {})
|
||||
check("undo_list 列了三步", "3 步" in listing, listing)
|
||||
check("看得到操作描述",
|
||||
"回退测试" in listing or "随机播放" in listing, listing)
|
||||
|
||||
print()
|
||||
print("四、开关的状态确实是开着的,回退要能关掉")
|
||||
check("shuffle_play 现在是开的", store.get("shuffle_play") is True,
|
||||
store.get("shuffle_play"))
|
||||
check("loop_play 现在是开的", store.get("loop_play") is True,
|
||||
store.get("loop_play"))
|
||||
|
||||
# 最近一步是 big_text,先退它
|
||||
result = features.run("undo_last", {})
|
||||
check("回退上一步成功", "已回退" in result, result)
|
||||
check("回退后列表少一条", len(features._undo_stack()) == 2,
|
||||
len(features._undo_stack()))
|
||||
|
||||
# 再退两步,应该把两个开关关掉
|
||||
features.run("undo_last", {})
|
||||
features.run("undo_last", {})
|
||||
check("shuffle_play 被关回去了", store.get("shuffle_play") is False,
|
||||
store.get("shuffle_play"))
|
||||
check("loop_play 被关回去了", store.get("loop_play") is False,
|
||||
store.get("loop_play"))
|
||||
check("列表清空了", len(features._undo_stack()) == 0,
|
||||
len(features._undo_stack()))
|
||||
|
||||
print()
|
||||
print("五、undo_all 批量回退")
|
||||
features.run("shuffle_play", {"on": True})
|
||||
features.run("loop_play", {"on": True})
|
||||
features.run("big_text", {"text": "批量测试"})
|
||||
check("攒了 3 步", len(features._undo_stack()) == 3,
|
||||
len(features._undo_stack()))
|
||||
result = features.run("undo_all", {})
|
||||
check("undo_all 说回退了 3 步", "3 步" in result, result)
|
||||
check("开关都回去了", store.get("shuffle_play") is False
|
||||
and store.get("loop_play") is False,
|
||||
f"{store.get('shuffle_play')}/{store.get('loop_play')}")
|
||||
check("列表空了", len(features._undo_stack()) == 0,
|
||||
len(features._undo_stack()))
|
||||
|
||||
print()
|
||||
print("六、撤不回来的操作不该被记录")
|
||||
# 这些都是破坏性的 / 不可逆的
|
||||
for name in ("kill_games", "clean_temp", "lock_now", "net_reset"):
|
||||
try:
|
||||
features.run(name, {})
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
check("破坏性操作没有进回退列表",
|
||||
len(features._undo_stack()) == 0, len(features._undo_stack()))
|
||||
check("IRREVERSIBLE 里有 kill_games",
|
||||
"kill_games" in Features.IRREVERSIBLE)
|
||||
check("IRREVERSIBLE 里有 delete_file",
|
||||
"delete_file" in Features.IRREVERSIBLE)
|
||||
check("IRREVERSIBLE 里有 shutdown",
|
||||
"shutdown" in Features.IRREVERSIBLE)
|
||||
|
||||
print()
|
||||
print("七、回退不会来回横跳")
|
||||
features.run("shuffle_play", {"on": True})
|
||||
stack_before = len(features._undo_stack())
|
||||
features.run("undo_last", {})
|
||||
check("回退后不会又记一条新的",
|
||||
len(features._undo_stack()) == stack_before - 1,
|
||||
f"{stack_before} -> {len(features._undo_stack())}")
|
||||
|
||||
print()
|
||||
print("八、全部 toggle 都能记录回退")
|
||||
toggles = [d for d in defs if d.get("kind") == "toggle"]
|
||||
# 别写死数量 —— 加功能时这里会假失败(relay_saver 就踩过一次)。
|
||||
# 真正要保证的是:开关数量合理,且**每一个**都能回退。
|
||||
check("开关数量合理(>= 15)", len(toggles) >= 15, len(toggles))
|
||||
check("开关类都算可回退",
|
||||
all(d["name"] not in Features.IRREVERSIBLE for d in toggles),
|
||||
str([d["name"] for d in toggles
|
||||
if d["name"] in Features.IRREVERSIBLE]))
|
||||
|
||||
ui.stop()
|
||||
print()
|
||||
print("=" * 60)
|
||||
print(f"通过 {passed} 项,失败 {failed} 项")
|
||||
return 0 if failed == 0 else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user