From cf61ead0ab61dd2cf25cfbe1f27dafe8e8742ff4 Mon Sep 17 00:00:00 2001 From: vincent Date: Wed, 28 Feb 2024 22:00:27 +0800 Subject: [PATCH] update --- README.md | 2 -- bin/gen_key_and_update_key.sh | 18 +++++------------- bin/main.sh | 3 +++ bin/remove_xray.sh | 4 ++++ bin/update_uuid.sh | 4 ++-- conf/key.txt | 4 ++-- 6 files changed, 16 insertions(+), 19 deletions(-) create mode 100644 bin/remove_xray.sh diff --git a/README.md b/README.md index 0af6ec2..73f8e20 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,6 @@ - docker-compose - jq - 用于查看json文件, 提取json文件信息. 编辑json文件 - qrencode - 用于生成二维码 -- openssl - 生成密钥 -- uuidgen - 生成uuid ## 启动和关闭 生成并设置密钥和uuid diff --git a/bin/gen_key_and_update_key.sh b/bin/gen_key_and_update_key.sh index 3037552..fc3cce4 100644 --- a/bin/gen_key_and_update_key.sh +++ b/bin/gen_key_and_update_key.sh @@ -1,21 +1,13 @@ #!/bin/bash -# Generate private key -private_key=$(openssl genpkey -algorithm X25519) - -# Extract public key from private key -public_key=$(echo "$private_key" | openssl pkey -pubout) - -public_key=$(echo "$public_key" | sed -n '2p' | tr -d '\n') -private_key=$(echo "$private_key" | sed -n '2p' | tr -d '\n') - # Save keys to key.txt -echo "Private_key: $private_key" > ../conf/key.txt -echo "Public_key: $public_key" >> ../conf/key.txt +xray x25519 > ../conf/key.txt echo "success save keys to key.txt" -# update config.json +private_key = $(grep "Public key" ../conf/key.txt | awk -F ': ' '{print $2}' + +# # update config.json jq ".inbounds[0].streamSettings.realitySettings.privateKey=\"$private_key\"" ../conf/config.json > ../conf/config_temp.json mv ../conf/config_temp.json ../conf/config.json -echo "success updated private key to config.json" +echo "生成和设置密钥成功." diff --git a/bin/main.sh b/bin/main.sh index 21e141b..d2d0e0e 100644 --- a/bin/main.sh +++ b/bin/main.sh @@ -1,5 +1,8 @@ #!/bin/bash +# 安装xray +bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install + # 生成uui, 写入到config.json文件 bash ./update_uuid.sh diff --git a/bin/remove_xray.sh b/bin/remove_xray.sh new file mode 100644 index 0000000..08c509b --- /dev/null +++ b/bin/remove_xray.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Remove Xray +bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ remove \ No newline at end of file diff --git a/bin/update_uuid.sh b/bin/update_uuid.sh index 91a05a3..6d2af16 100644 --- a/bin/update_uuid.sh +++ b/bin/update_uuid.sh @@ -1,7 +1,7 @@ #!/bin/bash # 生成 UUID -uuid=$(uuidgen -r 4) +uuid=$(xray uuid) # 使用 jq 修改 JSON 文件 jq ".inbounds[0].settings.clients[0].id=\"$uuid\"" ../conf/config.json > ../conf/config.json_tmp @@ -10,6 +10,6 @@ jq ".inbounds[0].settings.clients[0].id=\"$uuid\"" ../conf/config.json > ../conf mv ../conf/config.json_tmp ../conf/config.json # 验证结果 -echo "UUID 已更新为: $uuid" +echo "设置UUID成功." diff --git a/conf/key.txt b/conf/key.txt index a839089..3e12651 100644 --- a/conf/key.txt +++ b/conf/key.txt @@ -1,2 +1,2 @@ -Public_key: -Private_key: +Private key: KJ42elMcVqM1b0-5Ny3iCUZVlvelibWKnGoF1kdklig +Public key: 0hBmzH75m67yWOp6z7Z67WFHT7gJ6o3Nql5Jc5nC6WU \ No newline at end of file