From 8661527fc075df585c72e2466729a9776e1d9faa Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Mon, 29 Dec 2025 18:15:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=86=E4=BA=AB=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/print_share_link.sh | 12 +++++++++--- bin/utils/base.sh | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/bin/print_share_link.sh b/bin/print_share_link.sh index 9aa8ae8..830bf5e 100644 --- a/bin/print_share_link.sh +++ b/bin/print_share_link.sh @@ -24,21 +24,27 @@ print_share_link() { 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 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 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节点" - + # 构建分享链接 + 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 "IPV4: $ipv4" echo "port: $port" echo "uuid: $uuid" + echo "password: $password" echo "sni: $sni" + echo "congestion_control: $congestion_control" echo "" echo "分享链接: $share_link" echo -e "\033[0m" diff --git a/bin/utils/base.sh b/bin/utils/base.sh index 68b3198..77cdc74 100644 --- a/bin/utils/base.sh +++ b/bin/utils/base.sh @@ -97,3 +97,22 @@ gen_password() { 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" +} +