86 lines
3.2 KiB
Bash
86 lines
3.2 KiB
Bash
#!/bin/bash
|
|
|
|
print_reality_share_link(){
|
|
local script_dir="$(cd "$(dirname "${BASH_SOURCE[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"
|
|
|
|
local 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 "分享连接: $sub_ipv4"
|
|
echo ""
|
|
|
|
echo -e "\033[0m"
|
|
}
|
|
|
|
|
|
print_xhttp_reality_share_link(){
|
|
local script_dir="$(cd "$(dirname "${BASH_SOURCE[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"
|
|
|
|
local 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 ""
|
|
|
|
echo -e "\033[0m"
|
|
}
|
|
|
|
print_share_link(){
|
|
local script_dir="$(cd "$(dirname "${BASH_SOURCE[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
|