From 8298b39db90b09f65a6c47f82f3e2781dac097a9 Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Tue, 19 May 2026 18:17:39 +0800 Subject: [PATCH] update --- bin/utils/base.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/utils/base.sh b/bin/utils/base.sh index e8681fc..4dc21f3 100644 --- a/bin/utils/base.sh +++ b/bin/utils/base.sh @@ -99,6 +99,19 @@ check_config_file(){ echo "配置文件不是有效的JSON格式, 请重新生成配置文件." exit 1 fi + + # 使用singbox容器校验配置文件语义合法性 + echo "正在使用 sing-box 校验配置文件..." + local compose_file="$script_dir/../docker-compose.yml" + local singbox_image=$(grep 'image:' "$compose_file" | grep 'sing-box' | awk '{print $2}' | tr -d '"') + if ! docker run --rm \ + -v "$(realpath "$config_file"):/etc/sing-box/config.json:ro" \ + "$singbox_image" \ + check -c "/etc/sing-box/config.json"; then + echo "sing-box 配置文件校验失败, 请检查配置内容." + exit 1 + fi + } # 重启docker容器