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 + 鍙岃繛鎺?
鏂囨。
- 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
This commit is contained in:
xmz7891
2026-10-06 19:01:05 +08:00
commit b705216e4a
3195 changed files with 203292 additions and 0 deletions
+103
View File
@@ -0,0 +1,103 @@
# -*- coding: utf-8 -*-
"""修默认协议的判断。
问题:用户写 `192.168.2.156:8080`(不带协议头)时,
我之前一律补成 `https://` —— 但局域网中转服务的是**明文 HTTP**,
补成 https 就永远连不上,而且报错信息很误导。
判断规则:
IP 地址 / localhost / .local -> http:// (局域网,明文)
其它(域名) -> https:// (公网,必须加密)
这样用户随便写 `192.168.2.156:8080` 或 `relay.xxmxxs.top` 都能对。
"""
from __future__ import annotations
import re
import sys
from pathlib import Path
RELAY = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\windows"
r"\lanremote\relay.py")
OLD = ''' candidates = []
for piece in (url or "").replace(",", ";").split(";"):
piece = piece.strip().rstrip("/")
if not piece:
continue
if not piece.startswith(("http://", "https://")):
piece = "https://" + piece
if piece not in candidates:
candidates.append(piece)'''
NEW = ''' candidates = []
for piece in (url or "").replace(",", ";").split(";"):
piece = piece.strip().rstrip("/")
if not piece:
continue
if not piece.startswith(("http://", "https://")):
piece = _guess_scheme(piece) + piece
if piece not in candidates:
candidates.append(piece)'''
HELPER_ANCHOR = '''def _ssl_context() -> ssl.SSLContext:'''
HELPER = '''# 私有网段 + 回环,这些肯定是局域网,用明文 HTTP
_PRIVATE_HOST = re.compile(
r"^(?:localhost|127\\.|10\\.|192\\.168\\.|172\\.(?:1[6-9]|2\\d|3[01])\\.)"
r"|^\\d{1,3}(?:\\.\\d{1,3}){3}(?::\\d+)?$" # 纯 IP(含公网 IP)
r"|\\.local(?::\\d+)?$",
re.IGNORECASE)
def _guess_scheme(address: str) -> str:
"""用户没写 http/https 时,猜一个。
IP 地址 / localhost -> http://
局域网里的中转服务是明文 HTTP。如果猜成 https,永远连不上,
而且报的是 SSL 错误,很容易误导人去查证书。
域名 -> https://
走公网必须加密(Cloudflare 隧道本来就是 https)。
"""
host = address.split("/", 1)[0]
return "http://" if _PRIVATE_HOST.match(host) else "https://"
''' + HELPER_ANCHOR
def main() -> int:
text = RELAY.read_text(encoding="utf-8")
ok = True
# 需要 re 模块
if "\nimport re\n" not in text:
text = text.replace("import json\n", "import json\nimport re\n", 1)
print(" 加了 import re")
if "_guess_scheme" in text:
print(" 已经加过协议猜测")
else:
for old, new, tag in ((OLD, NEW, "start() 用 _guess_scheme"),
(HELPER_ANCHOR, HELPER, "_guess_scheme 函数")):
if old not in text:
print(f" [失败] {tag} —— 锚点没找到")
ok = False
continue
text = text.replace(old, new, 1)
print(f" {tag}")
RELAY.write_text(text, encoding="utf-8", newline="\n")
import ast
try:
ast.parse(text)
print(" 语法 OK")
except SyntaxError as exc:
print(f" 语法错误: {exc}")
ok = False
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())