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

103 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 -*-
"""修两个由之前修复引入的回归。
1. _resolve_received:我插入的相对路径检查提前 return None,
把后面"按文件名在接收目录里找"的逻辑整个挡住了 —— file_pull 全废。
相对路径要「检查完继续往下走」,而不是直接返回。
2. test_features.py:把「额外允许的目录」建在了数据目录里面,
被新的敏感目录检查拦住(行为正确,是测试的位置不对)。
"""
from __future__ import annotations
import sys
from pathlib import Path
SERVER = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\windows"
r"\lanremote\server.py")
TEST = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\_tests"
r"\test_features.py")
SRV_OLD = ''' # 相对路径也要过白名单。Path("data/settings.json").is_absolute() 是 False,
# 上面那一段挡不住它 —— 而 EXE 的 CWD 就是程序目录,
# 于是已配对设备能把 data/settings.json(配对码 + 全部设备令牌)拉走。
try:
relative = (Path.cwd() / raw).resolve()
except OSError:
return None
allowed_roots = [self.store.received_dir()]
if self.features is not None:
allowed_roots.extend(self.features.allowed_roots())
if self._is_sensitive(relative):
self._log(f"[文件] 拒绝拉取数据目录: {raw}")
return None
for root in allowed_roots:
try:
relative.relative_to(root.resolve())
return relative if relative.is_file() else None
except (ValueError, OSError):
continue
self._log(f"[文件] 拒绝拉取相对路径: {raw}")
return None'''
SRV_NEW = ''' # 相对路径也要过一遍检查。Path("data/settings.json").is_absolute() 是 False,
# 上面那一段挡不住它 —— 而 EXE 的 CWD 就是程序目录,
# 于是已配对设备能把 data/settings.json(配对码 + 全部设备令牌)拉走。
#
# 注意:这里**不能**因为"不在允许目录内"就 return None ——
# 后面的逻辑还要按文件名在接收目录里找。只有命中敏感目录时才直接拒绝。
try:
relative = (Path.cwd() / raw).resolve()
except OSError:
relative = None
if relative is not None:
if self._is_sensitive(relative):
self._log(f"[文件] 拒绝拉取数据目录: {raw}")
return None
allowed_roots = [self.store.received_dir()]
if self.features is not None:
allowed_roots.extend(self.features.allowed_roots())
for root in allowed_roots:
try:
relative.relative_to(root.resolve())
if relative.is_file():
return relative
break # 在允许目录内但不是文件,交给下面按名字找
except (ValueError, OSError):
continue
# 落到下面:按文件名在「接收目录」里找最新的那一份'''
# 测试:额外目录建在数据目录外面
TEST_OLD = ''' extra = tmp / "课件"'''
TEST_NEW = ''' # 额外目录要建在数据目录**外面** —— 数据目录整个都是敏感的
# (里面有配对码和设备令牌),建在里面会被正确地拒绝。
import tempfile as _tf
extra = Path(_tf.mkdtemp(prefix="lr_extra_")) / "课件"'''
def main() -> int:
ok = True
for path, old, new, tag in ((SERVER, SRV_OLD, SRV_NEW, "file_pull 按名字查找恢复"),
(TEST, TEST_OLD, TEST_NEW, "测试的额外目录挪出数据目录")):
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 (("server.py", SERVER), ("test_features.py", 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())