update
This commit is contained in:
parent
171b8764e9
commit
ab842b8551
@ -1,96 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
print_reality_share_link(){
|
||||
local script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径
|
||||
local config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径
|
||||
print_share_link() {
|
||||
local script_dir=$(cd "$(dirname "$0")"; pwd)
|
||||
local config_dir=$(readlink -f "$script_dir/../")
|
||||
source "${script_dir}/utils/base.sh"
|
||||
|
||||
# 获取本机IP
|
||||
# 检查jq是否安装
|
||||
check_jq
|
||||
|
||||
# 检查是否已启动过容器(假设UUID已替换为真实值,否则视为未启动)
|
||||
local uuid=$(jq -r '.inbounds[0].users[0].uuid' "$config_dir/config.json")
|
||||
if [ "$uuid" = "生成一个UUID替换这里" ] || [ -z "$uuid" ] || [[ "$uuid" == null ]]; then
|
||||
red "error: 容器未启动过或UUID未配置, 查看配置失败"
|
||||
echo '请选择"启动容器"或确保已手动替换UUID'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 读取配置文件内容
|
||||
local config=$(cat "$config_dir/config.json")
|
||||
|
||||
# 提取所需信息
|
||||
uuid=$(echo "$config" | jq -r '.inbounds[0].users[0].uuid')
|
||||
local sni=$(echo "$config" | jq -r '.inbounds[0].tls.server_name')
|
||||
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"
|
||||
local port=$(echo "$config" | jq -r '.inbounds[0].listen_port')
|
||||
|
||||
# 检查sni
|
||||
if [ "$sni" = "你的域名或伪装域名" ] || [ -z "$sni" ] || [[ "$sni" == null ]]; then
|
||||
sni="bing.com" # 可根据需要修改默认值
|
||||
fi
|
||||
|
||||
# 构建分享链接(基于常见TUIC v5客户端如NekoBox、SFA支持的格式)
|
||||
local share_link="tuic://$uuid@$ipv4:$port?sni=$sni&alpn=h3&insecure=1&allowInsecure=1&congestion_control=bbr#Tuic节点"
|
||||
|
||||
# 输出分享链接
|
||||
echo -e "\033[32m"
|
||||
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 ""
|
||||
echo "分享链接: $share_link"
|
||||
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
|
||||
print_share_link # 输出分享链接
|
||||
Loading…
Reference in New Issue
Block a user