mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 20:40: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 + 鍙岃繛鎺? 鏂囨。 - 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
74 lines
2.7 KiB
Python
74 lines
2.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""把最新的服务器端文件部署到设备并复核。"""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
sys.path.insert(0, str(ROOT / "_build"))
|
|
|
|
from devssh import upload, run # noqa: E402
|
|
|
|
FILES = (
|
|
(ROOT / "relay" / "relay.py", "/root/lanremote-relay/relay.py"),
|
|
(ROOT / "relay" / "watchdog.sh", "/root/lanremote-relay/watchdog.sh"),
|
|
(ROOT / "relay" / "tunnel-run.sh",
|
|
"/root/lanremote-relay/tunnel-run.sh"),
|
|
(ROOT / "relay" / "install.sh", "/root/lanremote-relay/install.sh"),
|
|
)
|
|
|
|
|
|
def main() -> int:
|
|
print("一、上传")
|
|
for local, remote in FILES:
|
|
raw = local.read_bytes()
|
|
# shell 脚本必须是 LF,否则设备上跑不起来
|
|
if raw.count(b"\r\n") and local.suffix == ".sh":
|
|
raw = raw.replace(b"\r\n", b"\n")
|
|
local.write_bytes(raw)
|
|
print(f" {local.name}: 修了 CRLF")
|
|
upload(str(local), remote, 0o755)
|
|
print(f" {local.name} -> {remote}")
|
|
|
|
print()
|
|
print("二、语法检查")
|
|
run("bash -n /root/lanremote-relay/watchdog.sh "
|
|
"&& bash -n /root/lanremote-relay/tunnel-run.sh "
|
|
"&& bash -n /root/lanremote-relay/install.sh "
|
|
"&& echo ' 三个脚本语法 OK'")
|
|
|
|
print()
|
|
print("三、重启并复核")
|
|
run("systemctl restart lanremote-relay; sleep 5; "
|
|
"printf ' %-32s %-10s %s\\n' 服务 运行 开机自启; "
|
|
"for s in lanremote-relay lanremote-tunnel lanremote-watchdog.timer; "
|
|
"do printf ' %-32s %-10s %s\\n' \"$s\" "
|
|
"\"$(systemctl is-active $s 2>/dev/null)\" "
|
|
"\"$(systemctl is-enabled $s 2>/dev/null)\"; done")
|
|
|
|
print()
|
|
print("四、健康检查")
|
|
run("curl -s --max-time 8 http://127.0.0.1:8080/v1/health | head -c 200")
|
|
print()
|
|
run("echo -n ' 公网地址: '; cat /root/lanremote-relay/public_url.txt")
|
|
run("echo -n ' 可达性: HTTP '; timeout 20 curl -4 -s -o /dev/null "
|
|
"-w '%{http_code}\\n' -H 'User-Agent: LanRemote/1.4.0' "
|
|
"https://relay.xxmxxs.top/v1/health")
|
|
|
|
print()
|
|
print("五、清掉测试残留(这次部署后又连上来的测试设备)")
|
|
run("KEY=$(cat /root/lanremote-relay/data/admin_key.txt); "
|
|
"curl -s --max-time 8 -X POST "
|
|
"http://127.0.0.1:8080/v1/admin/delete_all "
|
|
"-H \"X-Admin: $KEY\" -H 'Content-Type: application/json' -d '{}'")
|
|
print()
|
|
run("python3 -c \"import json; "
|
|
"d=json.load(open('/root/lanremote-relay/data/relay_state.json')); "
|
|
"print(' 剩余配对码绑定:', len(d.get('codes', [])))\"")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|