xray_docker/bin/update_reality_dest.sh
2025-11-22 16:34:18 +08:00

37 lines
1.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
update_realty_dest(){
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
# 如果未指定端口号默认加上 :443
if [[ "$dest" != *:* ]]; then
dest="${dest}:443"
echo "未检测到端口号,已自动添加默认端口 :443"
fi
domain=$(echo "$dest" | awk -F ':' '{print $1}')
# 修改配置文件的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\"]"
}