mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 17:10:43 +00:00
琚帶绔?- 淇 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 + 鍙岃繛鎺? 鏂囨。 - 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
98 lines
2.9 KiB
Python
98 lines
2.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""生成「网络自检.bat」—— 纯 ASCII,彻底避开编码坑。
|
|
|
|
真机问题:双击后中文全是乱码。
|
|
根因:.bat 用 GBK 存盘 + chcp 936,但用户机器上控制台代码页并不是 936
|
|
(可能开了「Beta: 使用 UTF-8 提供全球语言支持」),
|
|
于是 bat 自己的中文和 Python 的输出都花了。
|
|
|
|
彻底方案:
|
|
* **bat 里一个中文都不留**(纯 ASCII),只负责设 UTF-8 代码页并调用 Python
|
|
* 中文全部交给 Python 输出,Python 自己把控制台设成 65001
|
|
* 脚本名用通配符找(*.py),这样中文文件名也不影响纯 ASCII 的 bat
|
|
|
|
这样无论系统默认代码页是什么都不会乱。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
LINES = [
|
|
"@echo off",
|
|
"chcp 65001 >nul 2>nul",
|
|
"title LAN Remote - Network Self Check",
|
|
'cd /d "%~dp0"',
|
|
"",
|
|
"set \"PY=\"",
|
|
"where python >nul 2>nul && set \"PY=python\"",
|
|
'if not defined PY where py >nul 2>nul && set "PY=py"',
|
|
"if not defined PY goto NOPY",
|
|
"",
|
|
"rem Find the single .py next to this file (its name may be Chinese,",
|
|
"rem which would break this pure-ASCII launcher if hard-coded).",
|
|
'set "SCRIPT="',
|
|
'for %%f in ("%~dp0*.py") do if not defined SCRIPT set "SCRIPT=%%~ff"',
|
|
"if not defined SCRIPT goto NOFILE",
|
|
"",
|
|
"%PY% \"%SCRIPT%\"",
|
|
"goto END",
|
|
"",
|
|
":NOPY",
|
|
"echo.",
|
|
"echo [ERROR] Python not found (neither python nor py on PATH).",
|
|
"echo.",
|
|
"echo The self-check needs Python. Usually you do not need it -",
|
|
"echo use the Toolbox instead:",
|
|
"echo 1 Start agent",
|
|
"echo 2 Fix firewall",
|
|
"echo.",
|
|
"goto END",
|
|
"",
|
|
":NOFILE",
|
|
"echo.",
|
|
"echo [ERROR] No .py script found next to this .bat.",
|
|
"echo.",
|
|
"",
|
|
":END",
|
|
"echo.",
|
|
"pause",
|
|
]
|
|
|
|
|
|
def main() -> int:
|
|
target = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\tools\网络自检.bat")
|
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
with open(target, "w", encoding="ascii", newline="\r\n") as handle:
|
|
handle.write("\n".join(LINES) + "\n")
|
|
|
|
data = target.read_bytes()
|
|
crlf = data.count(b"\r\n")
|
|
lone = data.count(b"\n") - crlf
|
|
try:
|
|
data.decode("ascii")
|
|
ascii_ok = True
|
|
except UnicodeDecodeError:
|
|
ascii_ok = False
|
|
|
|
print(f" 路径: {target}")
|
|
print(f" 大小: {len(data)} 字节 CRLF={crlf} 裸LF={lone} 纯ASCII={ascii_ok}")
|
|
|
|
problems = []
|
|
if lone:
|
|
problems.append("存在裸 LF")
|
|
if not ascii_ok:
|
|
problems.append("含非 ASCII 字符")
|
|
if not any(b"*.py" in line for line in [data]):
|
|
problems.append("没有用通配符找 .py")
|
|
if problems:
|
|
for item in problems:
|
|
print(f" [失败] {item}")
|
|
return 1
|
|
print(" 自检: 通过")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|