#!/bin/bash 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") 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" } print_xhttp_reality_share_link(){ local script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径 local config_dir=$(readlink -f "$script_dir/../conf") # xray配置文件绝对路径 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" 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 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 ] || [ "$xhttp_path" = "null" ];then print_reality_share_link else print_xhttp_reality_share_link fi } print_share_link