xray_docker/bin/print_share_link.sh
2024-12-14 20:30:23 +08:00

41 lines
1.3 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
# 检查 jq 是否安装
if ! command -v jq &> /dev/null; then
echo "jq 未安装"
exit 1
fi
script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径
config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径
# 获取本机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)
target=$(jq -r '.inbounds[0].streamSettings.realitySettings.target' $config_dir/config.json)
sni=$(echo $target | awk -F ':' '{print $1}')
network="tcp"
public_key=$(cat $config_dir/key.txt | grep "Public" | awk -F ': ' '{print $2}')
# 打印配置信息
echo -e "\033[32m" # config info with green color
echo "IPV4: $ipv4"
echo "PORT: $port"
echo "UUID: $uuid"
echo "SNI: $sni"
echo "PUBLIC_KEY: $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 "IPV4 订阅连接: $sub_ipv4"
# 如果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"