关键代码验证
wget -P /root -N --no-check-certificate https//raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh && chmod 700 /root/install.sh && /root/install.sh
核心安装逻辑
一键安装命令分析
mack-a 脚本的标准安装命令如下:
wget -P /root -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh" && chmod 700 /root/install.sh && /root/install.sh
命令拆解:
-
wget 下载:
-P /root:指定下载路径为/root目录-N:只下载比本地文件新的版本,避免重复下载--no-check-certificate:跳过 SSL 证书验证(某些 VPS 系统时间不正确时必需)
-
权限设置:
chmod 700:设置脚本为仅所有者可读可写可执行,确保安全性
-
执行安装:
- 直接执行脚本,进入交互式安装流程
安装流程详解:
脚本执行后会经历以下阶段:
-
环境检测(1-3 分钟)
- 检测操作系统类型和版本
- 检查系统架构(x86_64/arm64)
- 验证网络连通性
- 检查是否已安装其他代理软件
-
依赖安装(2-5 分钟)
- 安装必要的系统依赖(curl、wget、jq 等)
- 安装或更新 Nginx 作为 Web 服务器
- 配置防火墙规则
-
核心选择(用户交互)
- 选择安装 Xray-core 或 sing-box
- 选择要部署的协议组合
- 配置端口和传输方式
-
证书申请(1-3 分钟)
- 自动安装 acme.sh 证书工具
- 申请 Let’s Encrypt 或 ZeroSSL 免费证书
- 配置自动续期任务
-
服务配置(自动完成)
- 生成 Xray/sing-box 配置文件
- 配置 Nginx 反向代理
- 设置 systemd 服务自启动
-
完成提示
- 显示节点分享链接
- 生成订阅链接
- 提示管理命令
vasma
安装流程拆解
完整安装示例(VLESS + Reality):
# 1. 执行安装命令
wget -P /root -N --no-check-certificate \
"https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh" \
&& chmod 700 /root/install.sh && /root/install.sh
# 2. 脚本启动后显示菜单
# ================================================
# 作者:mack-a
# 当前版本:v3.5.9
# GitHub:https://github.com/mack-a/v2ray-agent
# 描述:八合一共存脚本
# ================================================
# 3. 选择核心类型
# [1] Xray-core(推荐)
# [2] sing-box
# 请选择:1
# 4. 选择安装模式
# [1] 安装全部(默认)
# [2] 自定义安装
# 请选择:2
# 5. 选择协议(可多选)
# [1] VLESS+Reality+Vision
# [2] VLESS+Vision+TCP
# [3] VMess+WS+TLS
# ...
# 请选择:1
# 6. 配置端口
# 请输入端口(默认443):
# 7. 输入域名(Reality 可跳过)
# 请输入域名:example.com
# 8. 等待安装完成
# 安装过程约需 3-5 分钟
# 9. 安装完成,显示配置信息
# 节点链接:vless://...
# 订阅链接:https://example.com/subscribe/...
配置详解
核心配置文件结构
Xray 配置文件路径:/etc/v2ray-agent/xray/conf/
主要配置文件:
/etc/v2ray-agent/xray/conf/
├── 00_log.json # 日志配置
├── 02_VLESS_tcp_inbounds.json # VLESS 入站配置
├── 03_VLESS_vision_inbounds.json # VLESS Vision 入站
├── 04_VLESS_reality_inbounds.json # VLESS Reality 入站
├── 05_VMess_WS_inbounds.json # VMess WebSocket 入站
├── 06_trojan_tcp_inbounds.json # Trojan TCP 入站
├── 09_routing.json # 路由规则
├── 10_outbounds.json # 出站配置
└── 11_dns.json # DNS 配置
VLESS Reality 配置示例:
{
"inbounds": [
{
"port": 443,
"protocol": "vless",
"tag": "VLESSReality",
"settings": {
"clients": [
{
"id": "uuid-here",
"email": "user1@example.com",
"flow": "xtls-rprx-vision"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "tcp",
"security": "reality",
"realitySettings": {
"show": false,
"dest": "www.google.com:443",
"xver": 0,
"serverNames": [
"www.google.com",
"www.youtube.com"
],
"privateKey": "private-key-here",
"shortIds": [
"",
"0123456789abcdef"
]
}
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls",
"quic"
]
}
}
]
}
关键字段说明:
| 字段 | 说明 | 示例值 |
|---|---|---|
port | 监听端口 | 443 |
protocol | 协议类型 | vless / vmess / trojan |
clients.id | 用户 UUID | 550e8400-e29b-41d4-a716-446655440000 |
clients.flow | 流控模式 | xtls-rprx-vision / xtls-rprx-direct |
security | 安全层 | reality / tls / none |
realitySettings.dest | Reality 伪装目标 | www.google.com:443 |
realitySettings.serverNames | 允许的 SNI 列表 | [“www.google.com”] |
realitySettings.privateKey | Reality 私钥 | base64-encoded-key |
关键参数说明
Reality 参数详解:
-
dest(目标地址)
- 指定 Reality 回退的真实网站
- 推荐选择大流量、高可信度的网站
- 常用选择:www.google.com、www.cloudflare.com、www.apple.com
-
serverNames(服务器名称)
- 允许的 SNI(Server Name Indication)列表
- 客户端连接时必须使用列表中的域名
- 应包含 dest 中指定的域名
-
privateKey / publicKey
- Reality 使用的密钥对
- 私钥保存在服务器,公钥分发给客户端
- 脚本自动生成,无需手动创建
-
shortIds
- 短 ID 列表,用于多用户场景
- 空字符串 "" 为默认 ID
- 可添加多个短 ID 支持更多用户
证书配置参数:
{
"certificateFile": "/etc/v2ray-agent/tls/example.com.crt",
"keyFile": "/etc/v2ray-agent/tls/example.com.key"
}
证书由脚本自动管理,路径固定为 /etc/v2ray-agent/tls/。
使用命令指南
管理命令列表
安装完成后,可以使用以下命令管理服务:
# 打开管理菜单(最常用)
vasma
# 查看 Xray 服务状态
systemctl status xray
# 重启 Xray 服务
systemctl restart xray
# 查看 Xray 日志
journalctl -u xray -f
# 测试配置文件有效性
xray -test -config /etc/v2ray-agent/xray/conf/config.json
vasma 菜单功能:
========================================
V2Ray-Agent 管理脚本 v3.5.9
========================================
[1] 安装/重装
[2] 查看账号
[3] 添加用户
[4] 删除用户
[5] 更换端口
[6] 更换证书
[7] 更换伪装站
[8] 查看日志
[9] 卸载脚本
[10] 更新脚本
[11] 核心管理
[12] 分流工具
[13] 订阅管理
[14] 其他工具
[0] 退出
========================================
常见操作示例
1. 添加新用户:
# 执行管理菜单
vasma
# 选择 [3] 添加用户
# 输入用户邮箱(用于标识)
# 脚本自动生成 UUID 和分享链接
2. 查看节点链接:
# 执行管理菜单
vasma
# 选择 [2] 查看账号
# 显示所有用户的节点链接和二维码
3. 更换 Reality 伪装站:
# 执行管理菜单
vasma
# 选择 [7] 更换伪装站
# 选择新的伪装目标(如 youtube、microsoft 等)
# 脚本自动重新生成配置并重启服务
4. 启用 WARP 分流:
# 执行管理菜单
vasma
# 选择 [12] 分流工具
# 选择 [1] WARP 分流
# 按照提示安装 WARP 并配置分流规则
5. 备份配置:
# 备份整个配置目录
tar -czvf v2ray-backup-$(date +%Y%m%d).tar.gz /etc/v2ray-agent/
# 备份特定文件
cp /etc/v2ray-agent/xray/conf/config.json ~/config-backup.json
6. 更新核心版本:
# 执行管理菜单
vasma
# 选择 [11] 核心管理
# 选择 [1] 更新 Xray-core
# 选择要更新的版本(可回退到旧版本)
集成方案
与现有系统的集成
1. 与宝塔面板共存:
宝塔面板默认占用 80/443 端口,与脚本冲突。解决方案:
# 方法 1:修改宝塔端口
# 进入宝塔面板 -> 设置 -> 修改面板端口为 8888
# 在脚本安装时选择非 80/443 端口
# 方法 2:使用反向代理
# 在宝塔网站配置中添加反向代理规则
location / {
proxy_pass http://127.0.0.1:你的代理端口;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
2. 与 Nginx 集成:
脚本已内置 Nginx,如需自定义配置:
# Nginx 配置路径
/etc/nginx/conf.d/
# 修改后重载配置
nginx -t && systemctl reload nginx
3. 与 CDN 配合:
使用 Cloudflare 等 CDN 隐藏真实 IP:
# 1. 在 Cloudflare 添加域名解析
# 2. 将云朵设为橙色(代理模式)
# 3. SSL/TLS 模式设为 Full (strict)
# 4. 脚本选择 WebSocket 或 gRPC 传输方式
# 5. 在 Cloudflare 网络设置中启用 WebSockets
客户端配置导出
订阅链接格式:
脚本自动生成兼容多种客户端的订阅:
https://你的域名/subscribe/用户名
支持的客户端:
- v2rayN(Windows)
- v2rayNG(Android)
- Shadowrocket(iOS)
- Clash.Meta(多平台)
- Surfboard(Android)
手动配置示例(v2rayN):
- 复制脚本生成的 VLESS 链接
- 打开 v2rayN -> 服务器 -> 从剪贴板导入批量 URL
- 选择导入的节点,右键设为活动服务器
- 开启系统代理
Clash 配置示例:
proxies:
- name: "VLESS-Reality"
type: vless
server: your-domain.com
port: 443
uuid: your-uuid
network: tcp
tls: true
udp: true
flow: xtls-rprx-vision
servername: www.google.com
reality-opts:
public-key: your-public-key
short-id: ""
client-fingerprint: chrome
参考资料
- mack-a 脚本快速搭建教程 - 官方安装指南
- Xray 配置文档 - Xray 完整配置参考
- VLESS 协议规范 - VLESS 技术细节
- Reality 协议说明 - Reality 工作原理