From 0e9714c3f0c7000029a66b64fe24baf2fb72a281 Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Sat, 22 Nov 2025 17:08:41 +0800 Subject: [PATCH] update --- bin/create_config.sh | 43 +++++++++++++++++++++++++++++++++++++++- bin/run.sh | 3 +-- bin/update_port.sh | 4 ++-- bin/update_xhttp_path.sh | 2 +- conf/config.json | 4 ++-- 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/bin/create_config.sh b/bin/create_config.sh index e2a4eff..4e3822c 100644 --- a/bin/create_config.sh +++ b/bin/create_config.sh @@ -7,6 +7,9 @@ create_reality_config(){ # 检查jq是否安装 check_jq + config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径 + cp "$config_dir/template/reality_config.json" "$config_dir/config.json" + # 生成uui, 写入到config.json文件 bash $script_dir/update_uuid.sh @@ -19,4 +22,42 @@ create_reality_config(){ echo "初始化完成" } -create_reality_config \ No newline at end of file +create_xhttp_reality_config(){ + script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径 + source "$script_dir/utils/base.sh" + + # 检查jq是否安装 + check_jq + + config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径 + cp "$config_dir/template/reality_config.json" "$config_dir/config.json" + + # 生成uui, 写入到config.json文件 + bash $script_dir/update_uuid.sh + + # 生成密钥对, 修改config.json中的密钥属性 + bash $script_dir/update_key.sh + + # 生成xhttp_path, 写入到config.json文件 + bash $script_dir/update_xhttp_path.sh + + # 设置端口 + bash $script_dir/update_port.sh +} + + +create_config(){ + echo "请选择配置文件类型:" + echo "1. 创建reality配置" + echo "2. 创建xhttp_reality配置" + read -p "请输入选择 (1 或 2): " choice + case $choice in + 1) create_reality_config ;; + 2) create_xhttp_reality_config ;; + *) echo "无效选择,退出" ;; + esac +} + +create_config + + diff --git a/bin/run.sh b/bin/run.sh index aee89e2..adc77b6 100644 --- a/bin/run.sh +++ b/bin/run.sh @@ -5,13 +5,12 @@ config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径 # 如果配置文件不存在或者空白 if [ ! -e "$config_dir/config.json" ] || [ ! -s "$config_dir/config.json" ] ; then - cp "$config_dir/template/reality_config.json" "$config_dir/config.json" + bash "$script_dir/create_config.sh" fi # 如果配置未初始化 uuid=$(jq -r '.inbounds[0].settings.clients[0].id' "$config_dir/config.json") if [ "$uuid" = "你的UUID" ] || [ -z "$uuid" ]; then # 执行初始化脚本 - echo "正在执行初始化脚本..." bash "$script_dir/create_config.sh" fi diff --git a/bin/update_port.sh b/bin/update_port.sh index f17d6d8..23fc590 100644 --- a/bin/update_port.sh +++ b/bin/update_port.sh @@ -44,7 +44,7 @@ find_free_port() { return 1 } -change_port(){ +update_port(){ local script_dir=$(cd "$(dirname "$0")"; pwd) local config_dir="$script_dir/../conf" source "$script_dir/utils/jq_util.sh" @@ -54,4 +54,4 @@ change_port(){ echo "设置端口成功" } -change_port \ No newline at end of file +update_port \ No newline at end of file diff --git a/bin/update_xhttp_path.sh b/bin/update_xhttp_path.sh index dc25ff3..6e803f7 100644 --- a/bin/update_xhttp_path.sh +++ b/bin/update_xhttp_path.sh @@ -11,7 +11,7 @@ update_xhttp_path(){ echo "设置xhttp_path成功" - ## 修改config.json的xhttp_path + # 修改config.json的xhttp_path modify_json_file "$config_dir/config.json" ".inbounds[0].streamSettings.xhttpSettings.path" "$xhttp_path" } diff --git a/conf/config.json b/conf/config.json index c6ef4aa..35ce013 100644 --- a/conf/config.json +++ b/conf/config.json @@ -56,12 +56,12 @@ "security": "reality", "realitySettings": { "show": true, - "dest": "gitea.9001001.xyz:443", + "dest": "你的reality_dest:443", "xver": 0, "maxTimeDiff": 0, "minClientVer": "", "serverNames": [ - "gitea.9001001.xyz" + "你的reality_dest" ], "privateKey": "你的密钥", "shortIds": [