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 + 鍙岃繛鎺? 鏂囨。 - 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
133 lines
5.2 KiB
Python
133 lines
5.2 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""允许用户把自己的配对码设成任意 6-16 位。
|
||
|
||
为什么不是硬编码:
|
||
硬编码意味着**每一台装了这软件的被控端都是同一个码**,
|
||
而且这个码还会被打进手表 APK(APK 可以反编译)。
|
||
泄露一次 = 所有用户一起中招,这就是"默认密码"型漏洞。
|
||
|
||
让用户在自己的机器上设,性质完全不同:
|
||
这是你这台电脑的凭据,只存在你的 data/settings.json 里,
|
||
不出现在任何分发的文件里,你随时能改。
|
||
|
||
配套:
|
||
* 最少 6 位(6 位已经是 100 万种,加上现有的限速够用)
|
||
* 暴力枚举限速保留(10 次失败锁 5 分钟)
|
||
* 设置里能看、能改、能一键换回随机码
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\windows"
|
||
r"\lanremote")
|
||
CONFIG = ROOT / "config.py"
|
||
UI = ROOT / "ui.py"
|
||
|
||
# ---------------- config:设置码 ----------------
|
||
|
||
CONFIG_ANCHOR = ''' def pairing_code(self) -> str:
|
||
return self.get("pairing_code", "")'''
|
||
|
||
CONFIG_NEW = ''' MIN_CODE_LEN = 6
|
||
MAX_CODE_LEN = 16
|
||
|
||
def set_pairing_code(self, code: str) -> str:
|
||
"""设成用户自己的配对码。返回规范化后的值。
|
||
|
||
只存在本机 data/settings.json 里,不写进任何要分发的东西。
|
||
"""
|
||
cleaned = "".join(ch for ch in str(code or "").strip()
|
||
if ch.isdigit() or ch.isalpha())
|
||
if len(cleaned) < self.MIN_CODE_LEN:
|
||
raise ValueError(f"配对码至少 {self.MIN_CODE_LEN} 位")
|
||
if len(cleaned) > self.MAX_CODE_LEN:
|
||
raise ValueError(f"配对码最多 {self.MAX_CODE_LEN} 位")
|
||
with self._lock:
|
||
self.settings["pairing_code"] = cleaned
|
||
self.settings["pairing_created"] = time.time()
|
||
self.save_settings()
|
||
return cleaned
|
||
|
||
def pairing_code(self) -> str:
|
||
return self.get("pairing_code", "")'''
|
||
|
||
# ---------------- ui:设置里加一项 ----------------
|
||
|
||
UI_ANCHOR = ''' # ---- 开机自启 ----
|
||
row_label("开机自启", "开机后在后台静默运行,没有任何窗口")'''
|
||
|
||
UI_NEW = ''' # ---- 配对码 ----
|
||
row_label("配对码", "6-16 位,只存本机。配一次就记住,平时不用输")
|
||
code_row = tk.Frame(win, bg=BG)
|
||
code_row.pack(fill="x", padx=16)
|
||
ent_code = tk.Entry(code_row, bg=CARD, fg=FG, relief="flat",
|
||
font=FONT_SMALL, width=14,
|
||
highlightthickness=1, highlightbackground=BORDER)
|
||
ent_code.insert(0, str(self.store.pairing_code() or ""))
|
||
ent_code.pack(side="left", ipady=4)
|
||
|
||
def randomize():
|
||
"""换一组随机码。"""
|
||
ent_code.delete(0, "end")
|
||
ent_code.insert(0, self.store.new_pairing_code())
|
||
|
||
self._btn(code_row, "换随机码", randomize, width=9, last=True)
|
||
|
||
# ---- 开机自启 ----
|
||
row_label("开机自启", "开机后在后台静默运行,没有任何窗口")'''
|
||
|
||
UI_SAVE_ANCHOR = ''' # 开机自启(可能失败:权限/注册表被锁)'''
|
||
|
||
UI_SAVE_NEW = ''' # 配对码
|
||
code_note = ""
|
||
typed = ent_code.get().strip()
|
||
if typed and typed != self.store.pairing_code():
|
||
try:
|
||
self.store.set_pairing_code(typed)
|
||
code_note = f";配对码已改为 {typed}"
|
||
except ValueError as exc:
|
||
code_note = f";配对码没改({exc})"
|
||
|
||
# 开机自启(可能失败:权限/注册表被锁)'''
|
||
|
||
UI_LOG_ANCHOR = ''' self.log(f"设置已保存;已关闭:{'、'.join(off)}{auto_note}")
|
||
else:
|
||
self.log(f"设置已保存(音色={chosen},语速={rate}){auto_note}")'''
|
||
|
||
UI_LOG_NEW = ''' self.log(f"设置已保存;已关闭:{'、'.join(off)}"
|
||
f"{auto_note}{code_note}")
|
||
else:
|
||
self.log(f"设置已保存(音色={chosen},语速={rate})"
|
||
f"{auto_note}{code_note}")'''
|
||
|
||
|
||
def main() -> int:
|
||
ok = True
|
||
for path, old, new, tag in ((CONFIG, CONFIG_ANCHOR, CONFIG_NEW, "config: 自定义配对码"),
|
||
(UI, UI_ANCHOR, UI_NEW, "ui: 配对码输入框"),
|
||
(UI, UI_SAVE_ANCHOR, UI_SAVE_NEW, "ui: 保存配对码"),
|
||
(UI, UI_LOG_ANCHOR, UI_LOG_NEW, "ui: 日志文案")):
|
||
text = path.read_text(encoding="utf-8")
|
||
if old not in text:
|
||
print(f" [跳过] {tag} —— 锚点没找到")
|
||
ok = False
|
||
continue
|
||
path.write_text(text.replace(old, new, 1), encoding="utf-8")
|
||
print(f" {tag}: OK")
|
||
|
||
import ast
|
||
for label, path in (("config.py", CONFIG), ("ui.py", UI)):
|
||
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())
|