xray_docker/bin/print_share_link.sh

50 lines
1.6 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径
config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径
source "$script_dir/utils/base.sh"
# 检查jq是否安装
check_jq
# 检查是否已启动过容器
uuid=$(jq -r '.inbounds[0].settings.clients[0].id' $config_dir/config.json)
if [ "$uuid" = "你的UUID" ]; then
red "error: 容器未启动过, 查看配置失败"
echo '请选择"启动容器"'
exit 1
fi
# 获取本机IP
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)
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}')
# 打印配置信息
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#my_docker_vless_reality_vision"
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"