fix:legacy_json

This commit is contained in:
dichgrem
2025-08-14 22:29:40 +08:00
parent 0b5f0408ce
commit 67e1af851c

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# install_singbox.sh # install_singbox.sh
# 版本号 # 版本号
SCRIPT_VERSION="1.12.1" SCRIPT_VERSION="1.12.1-alapa"
set -euo pipefail set -euo pipefail
# 颜色定义 # 颜色定义
@@ -19,7 +19,8 @@ if [[ $EUID -ne 0 ]]; then
exit 1 exit 1
fi fi
CONFIG_DIR=/etc/singbox # 修复:使用正确的配置目录
CONFIG_DIR=/etc/sing-box
STATE_FILE="$CONFIG_DIR/state.env" STATE_FILE="$CONFIG_DIR/state.env"
BIN_NAME=sing-box BIN_NAME=sing-box
@@ -88,54 +89,72 @@ install_singbox() {
PUB_KEY=$(echo "$KEY_OUTPUT" | awk -F': ' '/PublicKey/ {print $2}') PUB_KEY=$(echo "$KEY_OUTPUT" | awk -F': ' '/PublicKey/ {print $2}')
SHORT_ID=$(openssl rand -hex 8) SHORT_ID=$(openssl rand -hex 8)
FP="chrome" FP="chrome"
SERVER_IP=$(curl -s https://ifconfig.me) SERVER_IP=$(curl -4 -s https://api.ipify.org)
PORT=443 PORT=443
SPX="/" SPX="/"
mkdir -p "$CONFIG_DIR" mkdir -p "$CONFIG_DIR"
# 修复:更新为新的配置格式
cat >"$CONFIG_DIR/config.json" <<EOF cat >"$CONFIG_DIR/config.json" <<EOF
{ {
"log": { "log": {
"disabled": false,
"level": "info" "level": "info"
}, },
"dns": { "dns": {
"servers": [ "servers": [
{ {
"address": "tls://8.8.8.8" "type": "tls",
"server": "8.8.8.8",
"server_port": 853,
"tls": {
"min_version": "1.2"
} }
] }
],
"strategy": "prefer_ipv4"
}, },
"inbounds": [ "inbounds": [
{ {
"type": "vless", "type": "vless",
"tag": "VLESSReality", "tag": "VLESSReality",
"listen": "::", "listen": "::",
"listen_port": 443, "listen_port": ${PORT},
"users": [ "users": [
{ {
"name": "$NAME", "name": "${NAME}",
"uuid": "$UUID", "uuid": "${UUID}",
"flow": "xtls-rprx-vision" "flow": "xtls-rprx-vision"
} }
], ],
"tls": { "tls": {
"enabled": true, "enabled": true,
"server_name": "$SNI", "server_name": "${SNI}",
"reality": { "reality": {
"enabled": true, "enabled": true,
"handshake": { "handshake": {
"server": "$SNI", "server": "${SNI}",
"server_port": 443 "server_port": 443
}, },
"private_key": "$PRIVATE_KEY", "private_key": "${PRIVATE_KEY}",
"short_id": "$SHORT_ID" "short_id": "${SHORT_ID}"
} }
} }
} }
], ],
"route": {
"rules": [
{
"type": "default",
"outbound": "direct"
}
]
},
"outbounds": [ "outbounds": [
{ {
"type": "direct" "type": "direct",
"tag": "direct"
} }
] ]
} }