This commit is contained in:
Olia Lisa 2025-08-15 21:43:15 +08:00
parent 5cab57adf4
commit e3801150c0
6 changed files with 89 additions and 14 deletions

View File

@ -20,22 +20,26 @@ ipv4=$(curl -4 -sSL --connect-timeout 3 --retry 2 ip.sb || echo "null")
uuid=$(jq -r '.inbounds[0].settings.clients[0].id' $config_dir/config.json)
port=$(jq -r '.inbounds[0].port' $config_dir/config.json)
target=$(jq -r '.inbounds[0].streamSettings.realitySettings.target' $config_dir/config.json)
sni=$(echo $target | awk -F ':' '{print $1}')
dest=$(jq -r '.inbounds[0].streamSettings.realitySettings.dest' $config_dir/config.json)
sni=$(echo $dest | awk -F ':' '{print $1}')
network="tcp"
public_key=$(cat $config_dir/key.txt | grep "Public" | awk -F ': ' '{print $2}')
# 打印配置信息
echo -e "\033[32m" # config info with green color
echo "IPV4: $ipv4"
echo "PORT: $port"
echo "UUID: $uuid"
echo "SNI: $sni"
echo "PUBLIC_KEY: $public_key"
echo "NETWORK: $network"
echo "ipv4: $ipv4"
echo "port: $port"
echo "uuid: $uuid"
echo "dest: $dest"
echo "sni: $sni"
echo "public_key: $public_key"
echo "network: $network"
if [ "$ipv4" != "null" ]; then
sub_ipv4="vless://$uuid@$ipv4:$port?encryption=none&security=reality&type=$network&sni=$sni&fp=chrome&pbk=$public_key&flow=xtls-rprx-vision#my_docker_vless_reality_vision"
echo ""
echo "IPV4 订阅连接: $sub_ipv4"
echo ""
# 如果qrencode安装了则打印二维码
if command -v qrencode &> /dev/null; then
echo -e "IPV4 订阅二维码:\n$(echo "$sub_ipv4" | qrencode -o - -t UTF8)"

View File

@ -2,13 +2,29 @@
script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径
config_dir="$script_dir/../conf"
source $script_dir/utils/jq_util.sh
old_port=$(jq -r '.inbounds[0].port' "$config_dir/config.json")
read -p "请输入新的端口[当前端口: $old_port]: " port
# 如果输入为空,退出脚本
if [[ -z "$port" ]]; then
echo "输入端口为空, 退出脚本"
exit 0
fi
# 修改端口
modify_json_file "$config_dir/config.json" ".inbounds[0].port" "$port"
echo "端口修改成功!新端口为: $port"
read -p "是否要重启容器? (y/N): " restart_choice
if [[ "$restart_choice" =~ ^[Yy]$ ]]; then
echo "正在重启容器..."
docker-compose -f $script_dir/../docker-compose.yml down
docker-compose -f $script_dir/../docker-compose.yml up -d
else
echo "已跳过重启,请手动重启容器使配置生效"
fi

View File

@ -0,0 +1,40 @@
#!/bin/bash
script_dir=$(cd "$(dirname "$0")"; pwd)
config_dir="$script_dir/../conf"
source $script_dir/utils/jq_util.sh
# 输入dest值
old_dest=$(jq -r '.inbounds[0].streamSettings.realitySettings.dest' "$config_dir/config.json")
read -p "请输入新的dest地址[当前地址: $old_dest]: " dest
# 如果输入dest为空
if [[ -z "$dest" ]]; then
echo "输入dest为空退出脚本"
exit 1
fi
domain=$(echo "$dest" | awk -F ':' '{print $1}')
echo "正在修改配置文件..."
# 修改配置文件的dest
modify_json_file "$config_dir/config.json" ".inbounds[0].streamSettings.realitySettings.dest" "$dest"
# 修改配置文件的serverNames
modify_json_file "$config_dir/config.json" ".inbounds[0].streamSettings.realitySettings.serverNames" "[\"$domain\"]"
echo "配置文件修改成功!"
echo "新的dest地址为: $dest"
echo "新的serverNames数组为: [\"$domain\"]"
read -p "是否要重启容器? (y/N): " restart_choice
if [[ "$restart_choice" =~ ^[Yy]$ ]]; then
echo "正在重启容器..."
docker-compose -f "$script_dir/../docker-compose.yml" down
docker-compose -f "$script_dir/../docker-compose.yml" up -d
else
echo "已跳过重启,请手动重启容器使配置生效"
fi

View File

@ -1,7 +1,9 @@
#!/bin/bash
# 修改json文件的属性值
# 调用方式modify_json_file "/foo/bar.json" "person.name" "张三"
# 案例1modify_json_file "/foo/bar.json" "person.name" "张三"
# 案例2modify_json_file "/foo/bar.json" "servers" '["a.com", "b.com"]'
# 该函数能自动处理不同数据类型,包括数组、对象和数字等。
function modify_json_file() {
local json_file=$1 # json文件路径
local key=$2 # 要修改的key
@ -12,6 +14,14 @@ function modify_json_file() {
key=${key:1}
fi
jq ".${key} = \"${value}\"" ${json_file} > ${json_file}.tmp
# 检查值是否为有效的 JSON 格式(如数组、对象或数字)。
# 如果是,则直接将值传递给 jq无需引号。
if echo "${value}" | jq . >/dev/null 2>&1; then
jq ".${key} = ${value}" "${json_file}" > "${json_file}.tmp"
else
# 否则,将值视为字符串,并添加引号。
jq ".${key} = \"${value}\"" "${json_file}" > "${json_file}.tmp"
fi
mv ${json_file}.tmp ${json_file}
}

View File

@ -56,7 +56,7 @@
"security": "reality",
"realitySettings": {
"show": true,
"target": "www.expedia.com:443",
"dest": "www.expedia.com:443",
"xver": 0,
"maxTimeDiff": 0,
"minClientVer": "",

View File

@ -6,7 +6,8 @@ echo "1. 启动容器"
echo "2. 查看分享链接"
echo "3. 停止容器"
echo "4. 更新镜像"
echo "5. 更新端口"
echo "5. 修改端口"
echo "6. 修改Reality目标域名"
echo "0. 退出"
# 读取用户选择
@ -34,9 +35,13 @@ case $choice in
bash ./bin/update_docker_images.sh
;;
5)
# 更新端口
# 修改端口
bash ./bin/update_port.sh
;;
6)
# 修改Reality目标域名
bash ./bin/update_reality_dest.sh
;;
0)
# 退出
echo "退出程序."