diff --git a/README.md b/README.md index aca7055..0f0a997 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ - curl - docker - docker-compose -- jq - 用于查看json文件, 提取json文件信息 +- jq - 用于查看json文件, 提取json文件信息. 编辑json文件 - qrencode - 用于生成二维码 ## 启动和关闭 diff --git a/bin/gen_key_and_update_key.sh b/bin/gen_key_and_update_key.sh new file mode 100644 index 0000000..3037552 --- /dev/null +++ b/bin/gen_key_and_update_key.sh @@ -0,0 +1,21 @@ +#!/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 +echo "success save keys to key.txt" + +# 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" + diff --git a/bin/main.sh b/bin/main.sh new file mode 100644 index 0000000..3ff42c2 --- /dev/null +++ b/bin/main.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# 生成uui +bash ./update_uuid.sh +bash ./gen_key_and_update_key.sh diff --git a/get_share_link.sh b/bin/print_share_link.sh old mode 100644 new mode 100755 similarity index 81% rename from get_share_link.sh rename to bin/print_share_link.sh index 314a4e7..fcf7759 --- a/get_share_link.sh +++ b/bin/print_share_link.sh @@ -16,12 +16,12 @@ fi # 获取本机IP IPV4=$(curl -4 -sSL --connect-timeout 3 --retry 2 ip.sb || echo "null") -UUID=$(jq -r '.inbounds[0].settings.clients[0].id' ./conf/config.json) -PORT=$(jq -r '.inbounds[0].port' ./conf/config.json) -DEST=$(jq -r '.inbounds[0].streamSettings.realitySettings.dest' ./conf/config.json) +UUID=$(jq -r '.inbounds[0].settings.clients[0].id' ../conf/config.json) +PORT=$(jq -r '.inbounds[0].port' ../conf/config.json) +DEST=$(jq -r '.inbounds[0].streamSettings.realitySettings.dest' ../conf/config.json) SNI=$(echo $DEST | awk -F ':' '{print $1}') NETWORK="tcp" -PUBLIC_KEY=$(cat ./conf/key.txt | grep "Public" | awk -F ': ' '{print $2}') +PUBLIC_KEY=$(cat ../conf/key.txt | grep "Public" | awk -F ': ' '{print $2}') # config info with green color echo -e "\033[32m" diff --git a/bin/update_uuid.sh b/bin/update_uuid.sh new file mode 100644 index 0000000..91a05a3 --- /dev/null +++ b/bin/update_uuid.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# 生成 UUID +uuid=$(uuidgen -r 4) + +# 使用 jq 修改 JSON 文件 +jq ".inbounds[0].settings.clients[0].id=\"$uuid\"" ../conf/config.json > ../conf/config.json_tmp + +# 替换原始文件 +mv ../conf/config.json_tmp ../conf/config.json + +# 验证结果 +echo "UUID 已更新为: $uuid" + + diff --git a/conf/config.json b/conf/config.json index 293d5d3..e5eecdd 100644 --- a/conf/config.json +++ b/conf/config.json @@ -45,7 +45,7 @@ "settings": { "clients": [ { - "id": "d1872fe4-9a9e-442b-87c9-74c779c56476", + "id": "c51f8991-42e5-4ff2-a028-5f10e02ec5b3", "flow": "xtls-rprx-vision" } ], @@ -63,7 +63,7 @@ "serverNames": [ "www.expedia.com" ], - "privateKey": "UArrjC-9qLXdvIHFz0SH1jSZ1CGctYxHYKrHZEH5E3A", + "privateKey": "MC4CAQAwBQYDK2VuBCIEIOA1cfypxpHE7utwoQPgM2RhHG9+UpjYd3QplfYaeNtv", "shortIds": [ "" ] diff --git a/conf/key.txt b/conf/key.txt index 20bf857..88b0dbd 100644 --- a/conf/key.txt +++ b/conf/key.txt @@ -1,2 +1,2 @@ -Private key: UArrjC-9qLXdvIHFz0SH1jSZ1CGctYxHYKrHZEH5E3A -Public key: Z-HcL71ZNbPshcMUdNK4pC0XkbS6vjRB8fTQQUsIEV4 +Public_key: MCowBQYDK2VuAyEA9w1zvcbc9RA/kpWH8crN0up5Gj00DzfSJSb3otrXbBo= +Private_key: MC4CAQAwBQYDK2VuBCIEIOA1cfypxpHE7utwoQPgM2RhHG9+UpjYd3QplfYaeNtv