From 0f29f6bf5ffd464a59b352518b6cbc782f4d1a9e Mon Sep 17 00:00:00 2001 From: chunzhi Date: Thu, 27 Mar 2025 11:49:35 -0400 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v2ray_installer.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/v2ray_installer.sh b/v2ray_installer.sh index 8a85da1..8eac28b 100644 --- a/v2ray_installer.sh +++ b/v2ray_installer.sh @@ -494,12 +494,54 @@ show_client_info() { echo -e "${YELLOW}WebSocket路径 (Path): /ray${PLAIN}" echo -e "${YELLOW}TLS: 开启${PLAIN}" echo -e "${YELLOW}-----------------------------${PLAIN}" + + # 生成VMess链接 + generate_vmess_link "${domain}" "${uuid}" + echo -e "${GREEN}提示:请确保客户端和服务器的时间误差在90秒内${PLAIN}" echo -e "${GREEN} 如果无法连接,可以尝试重启V2Ray服务:${PLAIN}" echo -e "${GREEN} systemctl restart v2ray${PLAIN}" echo -e "${YELLOW}-----------------------------${PLAIN}" } +# 生成VMess链接 +generate_vmess_link() { + local domain=$1 + local uuid=$2 + local remark="v2ray_${domain}" # 备注名称 + + # 构建VMess配置JSON + local vmess_json="{\"v\":\"2\",\"ps\":\"${remark}\",\"add\":\"${domain}\",\"port\":\"443\",\"id\":\"${uuid}\",\"aid\":\"0\",\"net\":\"ws\",\"type\":\"none\",\"host\":\"${domain}\",\"path\":\"/ray\",\"tls\":\"tls\"}" + + # Base64编码(确保适用于URL) + local vmess_link="" + if [ -x "$(command -v base64)" ]; then + # Linux标准base64命令 + vmess_link=$(echo -n "${vmess_json}" | base64 -w 0) + else + # Fallback到简化版本(不处理换行) + vmess_link=$(echo -n "${vmess_json}" | base64) + fi + + # 输出VMess链接 + echo -e "${GREEN}VMess链接 (可直接导入V2Ray客户端):${PLAIN}" + echo -e "${BLUE}vmess://${vmess_link}${PLAIN}" + + # 输出导入提示 + echo -e "${GREEN}使用方法:${PLAIN}" + echo -e "${YELLOW}1. 复制上面的VMess链接${PLAIN}" + echo -e "${YELLOW}2. 在V2Ray客户端中选择\"从剪贴板导入\"${PLAIN}" + echo -e "${YELLOW}3. 或扫描下方二维码${PLAIN}" + + # 如果有qrencode命令,则生成二维码 + if [ -x "$(command -v qrencode)" ]; then + qrencode -t ANSI "vmess://${vmess_link}" + else + echo -e "${YELLOW}提示:安装qrencode可显示配置二维码${PLAIN}" + echo -e "${YELLOW} apt install qrencode 或 yum install qrencode${PLAIN}" + fi +} + # 检查时间同步状态 check_time_sync() { echo -e "${BLUE}检查系统时间同步状态...${PLAIN}"