mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 23:00:44 +00:00
被控端 - 修复 MTU 问题:夹 MSS + 路径 MTU 探测(公网可用率 48% -> 100%) - 复用 HTTP 连接(免掉每次新建 TLS 的 30% 握手失败) - 每分钟回头找局域网,自动切回快 400 倍的路径 - 画面心跳帧:静止时省流量,客户端仍知道流是活的 - 锁屏时给出可操作的提示 手表端 - 内置 GTS Root R4 / GlobalSign Root CA,修 SSLHandshakeException - 连接错误翻译成人话(证书/时间/解析/超时分别提示) - 经中转连上后用服务器报的地址刷新已配对记录 - 新增局域网连接页面、服务器延迟检测 服务器端 - 支持 chunked 请求体(修每 16 秒一次的连接错乱与大面积 502) - 网络调优脚本 net-tune.sh(开机自动应用) - 管理页:批量删除、网络体检、下载区 - 隧道改 HTTP/2 + 双连接 文档 - 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
103 lines
3.8 KiB
Python
103 lines
3.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""让屏幕采集器在设置变化时重建。
|
|
|
|
原来的实现:
|
|
def _ensure_capturer(self):
|
|
if self._capturer is None:
|
|
self._capturer = ScreenCapturer(
|
|
max_width=..., quality=...)
|
|
return self._capturer
|
|
|
|
问题:**缓存住了**。改了 screen_max_width / screen_quality 之后,
|
|
正在推流的话新设置永远不生效 —— 用户会以为"改了没用"。
|
|
|
|
修法:记住建它时用的参数,参数变了就重建。
|
|
|
|
顺带把 relay_saver 里那句 reset_capturer() 去掉(Actions 上没这个方法,
|
|
写了也是白写)。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
|
|
SERVER = ROOT / "windows" / "lanremote" / "server.py"
|
|
FEATURES = ROOT / "windows" / "lanremote" / "features.py"
|
|
|
|
OLD = ''' def _ensure_capturer(self) -> ScreenCapturer | None:
|
|
if self._capturer is None:
|
|
self._capturer = ScreenCapturer(
|
|
max_width=int(self.store.get("screen_max_width", 480) or 480),
|
|
quality=int(self.store.get("screen_quality", 55) or 55))
|
|
return self._capturer'''
|
|
|
|
NEW = ''' def _ensure_capturer(self) -> ScreenCapturer | None:
|
|
"""拿到屏幕采集器。**设置变了要重建。**
|
|
|
|
以前只判断 self._capturer is None,于是改了分辨率/画质之后
|
|
正在推流的会话永远用旧设置 —— 用户会以为"改了没用"。
|
|
现在记住建它时用的参数,参数一变就重建。
|
|
"""
|
|
width = int(self.store.get("screen_max_width", 480) or 480)
|
|
quality = int(self.store.get("screen_quality", 55) or 55)
|
|
signature = (width, quality)
|
|
if self._capturer is not None and \\
|
|
getattr(self, "_capturer_signature", None) == signature:
|
|
return self._capturer
|
|
self._capturer = ScreenCapturer(max_width=width, quality=quality)
|
|
self._capturer_signature = signature
|
|
return self._capturer'''
|
|
|
|
INIT_OLD = ''' self._capturer: ScreenCapturer | None = None'''
|
|
INIT_NEW = ''' self._capturer: ScreenCapturer | None = None
|
|
# 建采集器时用的 (分辨率, 画质)。变了就重建,不然改设置不生效。
|
|
self._capturer_signature = None'''
|
|
|
|
FEAT_OLD = ''' # 正在推流的话要重建采集器,新设置才生效
|
|
try:
|
|
self.actions.reset_capturer()
|
|
except Exception: # noqa: BLE001
|
|
pass
|
|
return note'''
|
|
|
|
FEAT_NEW = ''' # 采集器那边会自己检测参数变化并重建(见 server._ensure_capturer),
|
|
# 这里不用额外做什么。
|
|
return note'''
|
|
|
|
|
|
def main() -> int:
|
|
ok = True
|
|
|
|
text = SERVER.read_text(encoding="utf-8")
|
|
for old, new, tag in ((OLD, NEW, "_ensure_capturer 按参数重建"),
|
|
(INIT_OLD, INIT_NEW, "__init__ 加签名字段")):
|
|
if old not in text:
|
|
print(f" [失败] {tag} —— 锚点没找到")
|
|
ok = False
|
|
continue
|
|
text = text.replace(old, new, 1)
|
|
print(f" server.py: {tag}")
|
|
SERVER.write_text(text, encoding="utf-8")
|
|
|
|
text = FEATURES.read_text(encoding="utf-8")
|
|
if FEAT_OLD in text:
|
|
text = text.replace(FEAT_OLD, FEAT_NEW, 1)
|
|
FEATURES.write_text(text, encoding="utf-8")
|
|
print(" features.py: 去掉无效的 reset_capturer 调用")
|
|
else:
|
|
print(" features.py: [跳过] 没找到那段(可能已改)")
|
|
|
|
import ast
|
|
for label, path in (("server.py", SERVER), ("features.py", FEATURES)):
|
|
try:
|
|
ast.parse(path.read_text(encoding="utf-8"))
|
|
except SyntaxError as exc:
|
|
print(f" {label} 语法错误: {exc}")
|
|
ok = False
|
|
return 0 if ok else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|