增加分享链接功能
This commit is contained in:
parent
557e8a6fb9
commit
8661527fc0
@ -24,21 +24,27 @@ print_share_link() {
|
|||||||
local sni=$(echo "$config" | jq -r '.inbounds[0].tls.server_name')
|
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 ipv4=$(curl -4 -sSL --connect-timeout 3 --retry 2 ip.sb || echo "null")
|
||||||
local port=$(echo "$config" | jq -r '.inbounds[0].listen_port')
|
local port=$(echo "$config" | jq -r '.inbounds[0].listen_port')
|
||||||
|
local password=$(echo "$config" | jq -r '.inbounds[0].users[0].password')
|
||||||
|
local congestion_control=$(echo "$config" | jq -r '.inbounds[0].congestion_control')
|
||||||
|
|
||||||
|
|
||||||
# 检查sni
|
# 检查sni
|
||||||
if [ "$sni" = "你的域名或伪装域名" ] || [ -z "$sni" ] || [[ "$sni" == null ]]; then
|
if [ "$sni" = "你的域名或伪装域名" ] || [ -z "$sni" ] || [[ "$sni" == null ]]; then
|
||||||
sni="bing.com" # 可根据需要修改默认值
|
sni="bing.com" # 可根据需要修改默认值
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 构建分享链接(基于常见TUIC v5客户端如NekoBox、SFA支持的格式)
|
# 构建分享链接
|
||||||
local share_link="tuic://$uuid@$ipv4:$port?sni=$sni&alpn=h3&insecure=1&allowInsecure=1&congestion_control=bbr#Tuic节点"
|
local share_link="tuic://$uuid:$password@$ipv4:$port?sni=$sni&alpn=h3&insecure=1&allowInsecure=1&congestion_control=bbr#Tuic节点"
|
||||||
|
share_link = $(url_encode "$share_link")
|
||||||
|
|
||||||
# 输出分享链接
|
# 输出分享链接
|
||||||
echo -e "\033[32m"
|
echo -e "\033[32m"
|
||||||
echo "IPV4: $ipv4"
|
echo "IPV4: $ipv4"
|
||||||
echo "port: $port"
|
echo "port: $port"
|
||||||
echo "uuid: $uuid"
|
echo "uuid: $uuid"
|
||||||
|
echo "password: $password"
|
||||||
echo "sni: $sni"
|
echo "sni: $sni"
|
||||||
|
echo "congestion_control: $congestion_control"
|
||||||
echo ""
|
echo ""
|
||||||
echo "分享链接: $share_link"
|
echo "分享链接: $share_link"
|
||||||
echo -e "\033[0m"
|
echo -e "\033[0m"
|
||||||
|
|||||||
@ -97,3 +97,22 @@ gen_password() {
|
|||||||
echo "$rand"
|
echo "$rand"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# URL编码
|
||||||
|
url_encode() {
|
||||||
|
local str="$1"
|
||||||
|
local encoded=""
|
||||||
|
local i char hex
|
||||||
|
|
||||||
|
for ((i = 0; i < ${#str}; i++)); do
|
||||||
|
char="${str:$i:1}"
|
||||||
|
case "$char" in
|
||||||
|
[a-zA-Z0-9.~_-]) encoded+="$char" ;;
|
||||||
|
*)
|
||||||
|
printf -v hex '%02X' "'$char"
|
||||||
|
encoded+="%$hex"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
echo "$encoded"
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user