mirror of
https://github.com/Dichgrem/singbox-example.git
synced 2025-12-16 20:02:00 -05:00
fix:json
This commit is contained in:
@@ -9,29 +9,20 @@
|
|||||||
"listen": "::",
|
"listen": "::",
|
||||||
"listen_port": 443,
|
"listen_port": 443,
|
||||||
"users":
|
"users":
|
||||||
[
|
[{ "name": "$NAME", "uuid": "$UUID", "flow": "xtls-rprx-vision" }],
|
||||||
{
|
|
||||||
"name": "AK-JP-100G",
|
|
||||||
"uuid": "singbox生成",
|
|
||||||
"flow": "xtls-rprx-vision",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"tls":
|
"tls":
|
||||||
{
|
{
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"server_name": "s0.awsstatic.com",
|
"server_name": "$SNI",
|
||||||
"reality":
|
"reality":
|
||||||
{
|
{
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"handshake":
|
"handshake": { "server": "$SNI", "server_port": 443 },
|
||||||
{ "server": "s0.awsstatic.com", "server_port": 443 },
|
"private_key": "$PRIVATE_KEY",
|
||||||
"private_key": "singbox生成",
|
"short_id": "$SHORT_ID",
|
||||||
"short_id": ["singbox生成"],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"outbounds": [{ "type": "direct" }, { "type": "dns", "tag": "dns-out" }],
|
"outbounds": [{ "type": "direct" }],
|
||||||
"route": { "rules": [{ "protocol": "dns", "outbound": "dns-out" }] },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,23 +93,49 @@ install_singbox() {
|
|||||||
mkdir -p "$CONFIG_DIR"
|
mkdir -p "$CONFIG_DIR"
|
||||||
cat >"$CONFIG_DIR/config.json" <<EOF
|
cat >"$CONFIG_DIR/config.json" <<EOF
|
||||||
{
|
{
|
||||||
"log": {"level": "info"},
|
"log": {
|
||||||
"dns": {"servers": [{"address": "tls://8.8.8.8"}]},
|
"level": "info"
|
||||||
"inbounds": [{
|
},
|
||||||
|
"dns": {
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"address": "tls://8.8.8.8"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"inbounds": [
|
||||||
|
{
|
||||||
"type": "vless",
|
"type": "vless",
|
||||||
"tag": "VLESSReality",
|
"tag": "VLESSReality",
|
||||||
"listen": "::",
|
"listen": "::",
|
||||||
"listen_port": 443,
|
"listen_port": 443,
|
||||||
"users": [{"name":"$NAME","uuid":"$UUID","flow":"xtls-rprx-vision"}],
|
"users": [
|
||||||
"tls": {"enabled":true,"server_name":"$SNI","reality":{
|
{
|
||||||
"enabled":true,
|
"name": "$NAME",
|
||||||
"handshake": {"server":"$SNI","server_port":443},
|
"uuid": "$UUID",
|
||||||
"private_key":"$PRIVATE_KEY",
|
"flow": "xtls-rprx-vision"
|
||||||
"short_id":["$SHORT_ID"]
|
}
|
||||||
}}
|
],
|
||||||
}],
|
"tls": {
|
||||||
"outbounds": [{"type":"direct"},{"type":"dns","tag":"dns-out"}],
|
"enabled": true,
|
||||||
"route": {"rules": [{"protocol":"dns","outbound":"dns-out"}]}
|
"server_name": "$SNI",
|
||||||
|
"reality": {
|
||||||
|
"enabled": true,
|
||||||
|
"handshake": {
|
||||||
|
"server": "$SNI",
|
||||||
|
"server_port": 443
|
||||||
|
},
|
||||||
|
"private_key": "$PRIVATE_KEY",
|
||||||
|
"short_id": "$SHORT_ID"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outbounds": [
|
||||||
|
{
|
||||||
|
"type": "direct"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@@ -173,10 +199,40 @@ status_singbox() {
|
|||||||
# 显示 VLESS Reality 链接
|
# 显示 VLESS Reality 链接
|
||||||
show_link() {
|
show_link() {
|
||||||
printf "${CYAN}===== 您的 VLESS Reality 链接 =====${NC}\n"
|
printf "${CYAN}===== 您的 VLESS Reality 链接 =====${NC}\n"
|
||||||
[[ -f "$STATE_FILE" ]] || {
|
|
||||||
printf "${RED}未找到状态文件,请先安装。${NC}\n"
|
# 如果状态文件不存在,尝试从 config.json 读取并生成
|
||||||
|
if [[ ! -f "$STATE_FILE" ]]; then
|
||||||
|
if [[ -f "$CONFIG_DIR/config.json" ]]; then
|
||||||
|
NAME=$(grep -oP '"name"\s*:\s*"\K[^"]+' "$CONFIG_DIR/config.json")
|
||||||
|
UUID=$(grep -oP '"uuid"\s*:\s*"\K[^"]+' "$CONFIG_DIR/config.json")
|
||||||
|
SNI=$(grep -oP '"server_name"\s*:\s*"\K[^"]+' "$CONFIG_DIR/config.json")
|
||||||
|
PUB_KEY=$(grep -oP '"public_key"\s*:\s*"\K[^"]+' "$CONFIG_DIR/config.json")
|
||||||
|
SHORT_ID=$(grep -oP '"short_id"\s*:\s*"\K[^"]+' "$CONFIG_DIR/config.json")
|
||||||
|
FP="chrome"
|
||||||
|
SERVER_IP=$(curl -s https://ifconfig.me)
|
||||||
|
PORT=443
|
||||||
|
SPX="/"
|
||||||
|
|
||||||
|
# 保存新的 state.env
|
||||||
|
mkdir -p "$CONFIG_DIR"
|
||||||
|
cat >"$STATE_FILE" <<EOF
|
||||||
|
NAME="$NAME"
|
||||||
|
SNI="$SNI"
|
||||||
|
UUID="$UUID"
|
||||||
|
PUB_KEY="$PUB_KEY"
|
||||||
|
SHORT_ID="$SHORT_ID"
|
||||||
|
FP="$FP"
|
||||||
|
SERVER_IP="$SERVER_IP"
|
||||||
|
PORT="$PORT"
|
||||||
|
SPX="$SPX"
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
printf "${RED}未找到配置文件,请先安装。${NC}\n"
|
||||||
return
|
return
|
||||||
}
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 读取 state.env
|
||||||
source "$STATE_FILE"
|
source "$STATE_FILE"
|
||||||
LINK="vless://${UUID}@${SERVER_IP}:${PORT}?security=reality&sni=${SNI}&fp=${FP}&pbk=${PUB_KEY}&sid=${SHORT_ID}&spx=${SPX}&type=tcp&flow=xtls-rprx-vision&encryption=none#${NAME}"
|
LINK="vless://${UUID}@${SERVER_IP}:${PORT}?security=reality&sni=${SNI}&fp=${FP}&pbk=${PUB_KEY}&sid=${SHORT_ID}&spx=${SPX}&type=tcp&flow=xtls-rprx-vision&encryption=none#${NAME}"
|
||||||
printf "${GREEN}%s${NC}\n\n" "$LINK"
|
printf "${GREEN}%s${NC}\n\n" "$LINK"
|
||||||
|
|||||||
Reference in New Issue
Block a user