This commit is contained in:
Olia Lisa 2025-11-23 17:45:45 +08:00
parent 0c58672c3b
commit 00e91414e6

View File

@ -1,49 +1,96 @@
#!/bin/bash
script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径
config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径
source "$script_dir/utils/base.sh"
# 检查jq是否安装
check_jq
print_reality_share_link(){
local script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径
local config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径
# 获取本机IP
local 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)
if [ "$uuid" = "你的UUID" ]; then
red "error: 容器未启动过, 查看配置失败"
echo '请选择"启动容器"'
exit 1
fi
local uuid=$(jq -r '.inbounds[0].settings.clients[0].id' $config_dir/config.json)
local port=$(jq -r '.inbounds[0].port' $config_dir/config.json)
local dest=$(jq -r '.inbounds[0].streamSettings.realitySettings.dest' $config_dir/config.json)
local sni=$(echo $dest | awk -F ':' '{print $1}')
local network="tcp"
local public_key=$(cat $config_dir/key.txt | grep "Password" | awk -F ': ' '{print $2}')
# 打印配置信息
echo -e "\033[32m" # config info with green color
echo "ipv4: $ipv4"
echo "port: $port"
echo "uuid: $uuid"
echo "dest: $dest"
echo "sni: $sni"
echo "publicKey/password: $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#我的最新vless机场"
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)"
fi
fi
echo -e "\033[0m"
}
# 获取本机IP
ipv4=$(curl -4 -sSL --connect-timeout 3 --retry 2 ip.sb || echo "null")
print_xhttp_reality_share_link(){
local script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径
local config_dir=$(readlink -f "$script_dir/../conf") # xray配置文件绝对路径
uuid=$(jq -r '.inbounds[0].settings.clients[0].id' $config_dir/config.json)
port=$(jq -r '.inbounds[0].port' $config_dir/config.json)
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 "Password" | awk -F ': ' '{print $2}')
local ipv4=$(curl -4 -sSL --connect-timeout 3 --retry 2 ip.sb || echo "null") # 本机IP
local uuid=$(jq -r '.inbounds[0].settings.clients[0].id' $config_dir/config.json)
local port=$(jq -r '.inbounds[0].port' $config_dir/config.json)
local dest=$(jq -r '.inbounds[0].streamSettings.realitySettings.dest' $config_dir/config.json)
local sni=$(echo $dest | awk -F ':' '{print $1}')
local network=$(jq -r '.inbounds[0].streamSettings.network' $config_dir/config.json)
local xhttp_path=$(jq -r ".inbounds[0].streamSettings.xhttpSettings.path" $config_dir/config.json)
local public_key=$(cat $config_dir/key.txt | grep "Password" | awk -F ': ' '{print $2}')
# 打印配置信息
echo -e "\033[32m" # config info with green color
echo "ipv4: $ipv4"
echo "port: $port"
echo "uuid: $uuid"
echo "dest: $dest"
echo "sni: $sni"
echo "publicKey/password: $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#我的最新vless机场"
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)"
# 打印配置信息
echo -e "\033[32m" # config info with green color
echo "ipv4: $ipv4"
echo "port: $port"
echo "uuid: $uuid"
echo "dest: $dest"
echo "sni: $sni"
echo "publicKey/password: $public_key"
echo "network: $network"
echo "xhttp_path: $xhttp_path"
if [ "$ipv4" != "null" ]; then
sub_ipv4="vless://$uuid@$ipv4:$port?encryption=none&security=reality&type=$network&sni=$sni&fp=chrome&pbk=$public_key&path=$xhttp_path&mode=auto#${ipv4}-my_xray_xhttp_reality"
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)"
fi
fi
fi
echo -e "\033[0m"
echo -e "\033[0m"
}
print_share_link(){
local script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径
local config_dir=$(readlink -f "$script_dir/../conf") # xray配置文件绝对路径
# 检查 jq 是否安装
source $script_dir/utils/base.sh
check_jq
local xhttp_path=$(jq -r ".inbounds[0].streamSettings.xhttpSettings.path" $config_dir/config.json)
if [ -z $xhttp_path ];then
print_reality_share_link
else
print_xhttp_reality_share_link
fi
}
print_share_link