Files
ykxmz/_build/fix_safety_switches.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

98 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 -*-
"""设置窗口补上四个安全开关。
审计发现:allow_run / allow_power / allow_screen / allow_new_pairing 的注释
都写着"可在界面关闭",但设置对话框里根本没有这四项 ——
用户只能手改 settings.json 才能关掉"任意命令执行"(默认还是开着的)。
另外:pairing_enabled 只在启动时读一次,运行中改设置不生效,这里一并修。
"""
from __future__ import annotations
import sys
from pathlib import Path
UI = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\windows"
r"\lanremote\ui.py")
# 1. 在「自定义命令」之后插入四个开关
ANCHOR = ''' row_label("自定义命令", "一行一个,格式:显示名=命令。手表只能选这里登记过的")
txt_cmds = textbox(str(self.store.get("extra_commands") or "").replace(";", "\\n"))
'''
ADDITION = ''' row_label("自定义命令", "一行一个,格式:显示名=命令。手表只能选这里登记过的")
txt_cmds = textbox(str(self.store.get("extra_commands") or "").replace(";", "\\n"))
# ---- 安全开关(遥控能做什么的底线,默认全开)----
row_label("允许的操作", "关掉之后手表就做不了这项,改了立刻生效")
safety = tk.Frame(win, bg=BG)
safety.pack(fill="x", padx=16)
var_run = tk.BooleanVar(value=bool(self.store.get("allow_run", True)))
var_power = tk.BooleanVar(value=bool(self.store.get("allow_power", True)))
var_screen = tk.BooleanVar(value=bool(self.store.get("allow_screen", True)))
var_pair = tk.BooleanVar(value=bool(self.store.get("allow_new_pairing", True)))
for text, var in (("远程执行命令", var_run),
("关机 / 重启 / 锁屏", var_power),
("屏幕共享 / 截屏", var_screen),
("允许新设备配对", var_pair)):
check = tk.Checkbutton(safety, text=text, variable=var, bg=BG, fg=FG,
activebackground=BG, selectcolor=CARD,
font=FONT_SMALL, anchor="w", bd=0,
highlightthickness=0)
check.pack(side="left")
'''
# 2. 保存时写入,并立刻同步到运行中的服务
SAVE_OLD = ''' self.store.set("file_roots", join_lines(txt_roots))
self.store.set("extra_apps", join_lines(txt_apps))
self.store.set("extra_commands", join_lines(txt_cmds))
self.log(f"设置已保存(音色={chosen},语速={rate})")'''
SAVE_NEW = ''' self.store.set("file_roots", join_lines(txt_roots))
self.store.set("extra_apps", join_lines(txt_apps))
self.store.set("extra_commands", join_lines(txt_cmds))
self.store.set("allow_run", bool(var_run.get()))
self.store.set("allow_power", bool(var_power.get()))
self.store.set("allow_screen", bool(var_screen.get()))
self.store.set("allow_new_pairing", bool(var_pair.get()))
# 立刻生效:pairing_enabled 原本只在启动时读一次
if getattr(self, "server", None) is not None:
self.server.pairing_enabled = bool(var_pair.get())
off = [name for name, var in (("执行命令", var_run), ("电源操作", var_power),
("屏幕共享", var_screen), ("新配对", var_pair))
if not var.get()]
if off:
self.log(f"设置已保存;已关闭:{'、'.join(off)}")
else:
self.log(f"设置已保存(音色={chosen},语速={rate})")'''
def main() -> int:
text = UI.read_text(encoding="utf-8")
ok = True
for old, new, tag in ((ANCHOR, ADDITION, "四个安全开关"),
(SAVE_OLD, SAVE_NEW, "保存并同步")):
if old not in text:
print(f" [失败] {tag} 锚点没找到")
ok = False
else:
text = text.replace(old, new, 1)
print(f" {tag}: OK")
if ok:
UI.write_text(text, encoding="utf-8")
import ast
try:
ast.parse(UI.read_text(encoding="utf-8"))
print(" ui.py: 语法 OK")
except SyntaxError as exc:
print(f" ui.py: 语法错误 {exc}")
ok = False
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())