Files
ykxmz/_build/fix_server_const.py
T
xmz7891 b62ac865ea ykxmz 1.5.0:修复手表端 TLS 证书校验 + MTU 修复网络稳定性
被控端
- 修复 MTU 问题:夹 MSS + 路径 MTU 探测(公网可用率 48% -> 100%)
- 复用 HTTP 连接(免掉每次新建 TLS 的 30% 握手失败)
- 每分钟回头找局域网,自动切回快 400 倍的路径
- 画面心跳帧:静止时省流量,客户端仍知道流是活的
- 锁屏时给出可操作的提示

手表端
- 内置 GTS Root R4 / GlobalSign Root CA,修 SSLHandshakeException
- 连接错误翻译成人话(证书/时间/解析/超时分别提示)
- 经中转连上后用服务器报的地址刷新已配对记录
- 新增局域网连接页面、服务器延迟检测

服务器端
- 支持 chunked 请求体(修每 16 秒一次的连接错乱与大面积 502)
- 网络调优脚本 net-tune.sh(开机自动应用)
- 管理页:批量删除、网络体检、下载区
- 隧道改 HTTP/2 + 双连接

文档
- 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
2026-10-06 19:01:05 +08:00

101 lines
3.3 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 -*-
"""修:DEFAULT_RELAY_URL 被插进了 __init__ 里面。
我用的锚点 "# 跨网络中转链路(配了 relay_url 才会启用)" 在类内部,
于是常量定义被插到了方法体中间,把 __init__ 切断了:
self._lock = threading.RLock()
# 内置的中转地址。...
# 用户一个地址都不用填。
...
DEFAULT_RELAY_URL = "..."
# 跨网络中转链路(配了 relay_url 才会启用)
self._relay = None <-- 缩进对不上了
修法:
1. 把插错的那一整块从方法体里删掉
2. 把常量放到模块级(类定义之前)
"""
from __future__ import annotations
import ast
import re
import sys
from pathlib import Path
SERVER = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\windows"
r"\lanremote\server.py")
# 被插错的那一块(从"内置的中转地址"到最后那个注释行)
WRONG_BLOCK = re.compile(
r"\n # 内置的中转地址。没配过就用它[\s\S]*?"
r"# 跨网络中转链路(配了 relay_url 才会启用)\n")
MODULE_CONST = '''# 内置的中转地址。没配过就用它,这样电脑端跑起来就能连,
# 用户一个地址都不用填。
#
# 为什么是两个并用分号隔开:
# 随身 WiFi 和电脑经常在同一个局域网 -> 走第一个(局域网直连,
# 几十毫秒,而且地址永远不变)
# 电脑在外面 -> 第一个连不上,自动切第二个(Cloudflare 隧道,
# 600 毫秒左右,地址固定 relay.xxmxxs.top)
DEFAULT_RELAY_URL = "192.168.2.156:8080;https://relay.xxmxxs.top"
'''
def main() -> int:
text = SERVER.read_text(encoding="utf-8")
m = WRONG_BLOCK.search(text)
if not m:
print(" [失败] 找不到插错的那一块")
return 1
print(f" 找到插错的块({len(m.group(0))} 字符)")
# 1. 删掉,并把那句注释还回去
text = text[:m.start()] + \
"\n # 跨网络中转链路(配了 relay_url 才会启用)\n" + \
text[m.end():]
# 2. 常量放到模块级:找 "class RemoteServer" 那一行
anchor = "class RemoteServer"
index = text.find(anchor)
if index < 0:
print(" [失败] 找不到 class RemoteServer")
return 1
text = text[:index] + MODULE_CONST + text[index:]
print(" 常量已挪到模块级(class RemoteServer 之前)")
SERVER.write_text(text, encoding="utf-8", newline="\n")
try:
ast.parse(text)
print(" 语法 OK")
except SyntaxError as exc:
print(f" 语法还是错: 行 {exc.lineno}: {exc.msg}")
if exc.text:
print(f" {exc.text.rstrip()}")
return 1
# 3. 复核关键位置
lines = text.splitlines()
for i, line in enumerate(lines, 1):
if line.startswith("DEFAULT_RELAY_URL"):
print(f" 常量在模块级第 {i} 行")
if "class RemoteServer" in line:
print(f" 类在第 {i} 行")
if "self._relay = None" in line:
print(f" self._relay 在第 {i} 行,缩进 {len(line) - len(line.lstrip())}")
# 4. 确认 DEFAULT_RELAY_URL 只出现两次(定义 + 使用)
count = text.count("DEFAULT_RELAY_URL")
print(f" DEFAULT_RELAY_URL 出现 {count} 次(应为 2:定义 + 使用)")
return 0
if __name__ == "__main__":
sys.exit(main())