mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 21:50:44 +00:00
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:
@@ -0,0 +1,192 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""安卓端改造:
|
||||
|
||||
用户要求:
|
||||
1. "安卓端中转设置下面,把那个设备诊断给删了,换成输入配对码,
|
||||
输入对应配对码就可以连接对应电脑"
|
||||
2. "既然你现在用中转站了,之前那些局域网的那些东西也可以删掉了"
|
||||
|
||||
删:
|
||||
* 「连不上?点这里诊断」按钮 + openDiagPanel()
|
||||
* 「手动输入地址」按钮 + toggleManual() + manualBox(电脑 IP / 端口 输入)
|
||||
* foundBox / discovering(局域网搜索的残留)
|
||||
* Discovery.requestSelfCheck(局域网广播让电脑弹自检窗)
|
||||
加:
|
||||
* 「输入配对码连接」按钮:弹个框输 6 位数字,
|
||||
经中转直接连到对应电脑(不用先搜 IP)
|
||||
|
||||
保留:
|
||||
* 中转设置(这是现在的核心)
|
||||
* 已配对电脑的令牌自动重连(quickConnect)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
MAIN = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\android\src"
|
||||
r"\com\lanremote\watch\MainActivity.java")
|
||||
|
||||
|
||||
def drop_method(text: str, header_pattern: str) -> tuple:
|
||||
"""按花括号配平删掉一个方法(连前面的注释行一起)。"""
|
||||
lines = text.splitlines(keepends=True)
|
||||
start = None
|
||||
for index, line in enumerate(lines):
|
||||
if re.search(header_pattern, line):
|
||||
start = index
|
||||
break
|
||||
if start is None:
|
||||
return text, False
|
||||
depth = 0
|
||||
seen = False
|
||||
end = None
|
||||
for index in range(start, len(lines)):
|
||||
depth += lines[index].count("{")
|
||||
if "{" in lines[index]:
|
||||
seen = True
|
||||
depth -= lines[index].count("}")
|
||||
if seen and depth <= 0:
|
||||
end = index
|
||||
break
|
||||
if end is None:
|
||||
return text, False
|
||||
while start > 0 and lines[start - 1].strip().startswith("//"):
|
||||
start -= 1
|
||||
while end + 1 < len(lines) and lines[end + 1].strip() == "":
|
||||
end += 1
|
||||
del lines[start:end + 1]
|
||||
return "".join(lines), True
|
||||
|
||||
|
||||
# ---------- 1. 把设备诊断按钮换成"输入配对码连接" ----------
|
||||
|
||||
BTN_OLD = ''' Button selfCheck = bigButton("连不上?点这里诊断", C_WARN, 15);
|
||||
LinearLayout.LayoutParams scParams = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, dp(52));
|
||||
scParams.setMargins(0, 0, 0, dp(8));
|
||||
selfCheck.setLayoutParams(scParams);
|
||||
selfCheck.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openDiagPanel();
|
||||
}
|
||||
});
|
||||
box.addView(selfCheck);'''
|
||||
|
||||
BTN_NEW = ''' // 输入配对码直接连对应电脑。
|
||||
// 不再需要"先搜局域网 / 手动填 IP"那一套 ——
|
||||
// 现在统一经中转,配对码就是找电脑的唯一凭据。
|
||||
Button codeButton = bigButton("输入配对码连接", C_OK, 15);
|
||||
LinearLayout.LayoutParams codeParams = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, dp(52));
|
||||
codeParams.setMargins(0, 0, 0, dp(8));
|
||||
codeButton.setLayoutParams(codeParams);
|
||||
codeButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
promptPairingCode();
|
||||
}
|
||||
});
|
||||
box.addView(codeButton);'''
|
||||
|
||||
|
||||
def main() -> int:
|
||||
text = MAIN.read_text(encoding="utf-8")
|
||||
ok = True
|
||||
|
||||
# ---- 1. 按钮替换 ----
|
||||
if BTN_OLD in text:
|
||||
text = text.replace(BTN_OLD, BTN_NEW, 1)
|
||||
print(" 首页:设备诊断按钮 -> 输入配对码连接")
|
||||
else:
|
||||
print(" [失败] 找不到设备诊断按钮")
|
||||
ok = False
|
||||
|
||||
# ---- 2. 删 foundBox / discovering / btnManual 的创建段 ----
|
||||
text, done = drop_method(text, r"private void toggleManual\(\)")
|
||||
print(f" {'删掉' if done else '[跳过]'} toggleManual()")
|
||||
|
||||
# btnManual 按钮创建(从 btnManual = bigButton 到 box.addView(btnManual);)
|
||||
idx = text.find("btnManual = bigButton(")
|
||||
if idx >= 0:
|
||||
end = text.find("box.addView(btnManual);", idx)
|
||||
if end >= 0:
|
||||
end = text.find("\n", end) + 1
|
||||
text = text[:idx] + text[end:]
|
||||
print(" 删掉「手动输入地址」按钮")
|
||||
else:
|
||||
print(" [跳过] 找不到 btnManual 的挂载点")
|
||||
else:
|
||||
print(" [跳过] 没有 btnManual 创建段")
|
||||
|
||||
# manualBox(电脑 IP / 端口 输入)
|
||||
idx = text.find("manualBox = new LinearLayout(")
|
||||
if idx < 0:
|
||||
idx = text.find("LinearLayout manualBox")
|
||||
if idx >= 0:
|
||||
# 往前找声明行所在语句
|
||||
end = text.find("box.addView(manualBox);", idx)
|
||||
if end >= 0:
|
||||
end = text.find("\n", end) + 1
|
||||
text = text[:idx] + text[end:]
|
||||
print(" 删掉 manualBox(电脑 IP / 端口 输入)")
|
||||
|
||||
# foundBox 创建段
|
||||
idx = text.find("foundBox = new LinearLayout(this);")
|
||||
if idx >= 0:
|
||||
end = text.find("box.addView(foundBox);", idx)
|
||||
if end >= 0:
|
||||
end = text.find("\n", end) + 1
|
||||
text = text[:idx] + text[end:]
|
||||
print(" 删掉 foundBox(局域网搜索结果列表)")
|
||||
|
||||
# ---- 3. 删 openDiagPanel() ----
|
||||
text, done = drop_method(text, r"private void openDiagPanel\(\)")
|
||||
print(f" {'删掉' if done else '[跳过]'} openDiagPanel()")
|
||||
|
||||
# ---- 4. 删设备诊断那一整段(诊断面板的辅助方法)----
|
||||
for pattern, label in (
|
||||
(r"private void runDiagnostics\(", "runDiagnostics()"),
|
||||
(r"private void copyDiagToClipboard\(", "copyDiagToClipboard()"),
|
||||
(r"private String buildDiagText\(", "buildDiagText()")):
|
||||
text, done = drop_method(text, pattern)
|
||||
if done:
|
||||
print(f" 删掉 {label}")
|
||||
|
||||
# ---- 5. 删掉局域网广播自检那段 ----
|
||||
old_block = re.search(
|
||||
r"\n[ \t]*//[^\n]*连不上时:广播请求[^\n]*\n"
|
||||
r"(?:[^\n]*\n)*?[^\n]*Discovery\.requestSelfCheck[^\n]*\n"
|
||||
r"(?:[^\n]*\n)*?[ \t]*\}\);\n[ \t]*\}\)\.start\(\);\n",
|
||||
text)
|
||||
if old_block:
|
||||
text = text[:old_block.start()] + "\n" + text[old_block.end():]
|
||||
print(" 删掉局域网广播自检(Discovery.requestSelfCheck)")
|
||||
else:
|
||||
# 退一步:只把那一个方法删掉
|
||||
text, done = drop_method(text, r"private void requestSelfCheck")
|
||||
print(f" {'删掉' if done else '[跳过]'} 局域网广播自检")
|
||||
|
||||
# ---- 6. 删掉相关字段声明 ----
|
||||
for field in ("private LinearLayout foundBox;",
|
||||
"private boolean discovering = false;",
|
||||
"private Button btnManual;",
|
||||
"private EditText hostInput;",
|
||||
"private EditText portInput;",
|
||||
"private LinearLayout manualBox;",
|
||||
"private boolean manualOpen = false;"):
|
||||
if field in text:
|
||||
# 连同紧跟的注释行一起删
|
||||
text = re.sub(r"[ \t]*//[^\n]*\n(?=[ \t]*"
|
||||
+ re.escape(field) + ")", "", text, count=1)
|
||||
text = text.replace(field + "\n", "", 1)
|
||||
print(f" 删掉字段 {field.split()[-1]}")
|
||||
|
||||
MAIN.write_text(text, encoding="utf-8", newline="\n")
|
||||
return 0 if ok else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user