23 lines
607 B
Bash
23 lines
607 B
Bash
#!/bin/bash
|
|
|
|
update_key(){
|
|
|
|
script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径
|
|
config_dir="$script_dir/../conf"
|
|
source $script_dir/utils/jq_util.sh
|
|
|
|
# 使用docker运行xray镜像生成密钥文件
|
|
docker run --rm teddysun/xray:latest /usr/bin/xray x25519 > $config_dir/key.txt
|
|
|
|
# 获取私钥
|
|
private_key=$(grep "Private" $config_dir/key.txt | awk -F ': ' '{print $2}')
|
|
|
|
# 修改config.json密钥属性
|
|
modify_json_file "$config_dir/config.json" ".inbounds[0].streamSettings.realitySettings.privateKey" "$private_key"
|
|
|
|
echo "生成和设置密钥成功."
|
|
|
|
}
|
|
|
|
|
|
update_key |