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

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())