VMess — Xray-core
VMess 是经典的 AEAD-only V2Ray 协议。Xray-core 仅支持 AEAD 变体 —— 基于 alterId 的 MD5-AEAD 旧模式已被移除。运行时启动时会打印弃用 提示,建议改用 VLESS 加密(infra/conf/vmess.go:67, 118)。
入站
"protocol": "vmess" 入站的 settings:
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
users | []json.RawMessage | — | <user object array> | … | 入站账户列表;对象形状与 `clients` 相同。`users` 是近期 Xray 引入的较新名称,与 `clients` 一并接受。 |
clients | []json.RawMessage | (required) | <user object array> | 可接受的用户列表。每个条目包含 VMess 账户字段(id、security、experiments)与通用用户字段(email、level)。 |
default | *VMessDefaultConfig | (unset) | VMessDefaultConfig | 传入连接不匹配任何已配置 client 时使用的默认设置。目前只有 `level` 字段。 |
源码: infra/conf/vmess.go:61-65 · 锚定版本 v26.6.1 (94ffd50)
default
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
level | byte | 0 | <byte> | fallback 用户使用的策略等级。 |
源码: infra/conf/vmess.go:50-52 · 锚定版本 v26.6.1 (94ffd50)
clients[] —— 用户对象
clients[] 中每个条目都是 VMessAccount 加通用用户字段 (email、level):
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
id | string | (required) | <UUID> | 用户 UUID。规范 8-4-4-4-12 形式或去掉横线的 hex;加载时解析并重规范化。 |
security | string | auto | auto | aes-128-gcm | chacha20-poly1305 | none | zero | VMess 载荷的对称加密。`auto` 在 x86+AES-NI 上选 AES-GCM,其他平台选 ChaCha20。`zero` 禁用加密(仅靠握手保护)。 |
experiments | string | (unset) | <string> | 以逗号分隔的实验性标志,会被转发到协议层(在 protobuf 中作为 `TestsEnabled`)。 |
源码: infra/conf/vmess.go:18-22 · 锚定版本 v26.6.1 (94ffd50)
出站
"protocol": "vmess" 出站的 settings:
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
address | *Address | (unset) | <host> | 简化形式 —— 服务器主机名或 IP。设置后内部自动构造 `vnext`。 |
port | uint16 | (required with address) | <port> | 服务器端口(简化形式)。 |
level | uint32 | 0 | <uint32> | 用户等级(简化形式)。 |
email | string | (unset) | <string> | 统计中显示的用户标识。 |
id | string | (required with address) | <UUID> | 用户 UUID(简化形式)。 |
security | string | auto | auto | aes-128-gcm | chacha20-poly1305 | none | zero | 可选加密集合与入站 client 一致。 |
experiments | string | (unset) | <string> | 转发到服务端的实验性标志。 |
vnext | []*VMessOutboundTarget | (use simplified shape) | [{address,port,users:[user]}] | 完整形式 —— 必须恰好一个服务器恰好一个用户。 |
源码: infra/conf/vmess.go:115-124 · 锚定版本 v26.6.1 (94ffd50)
简化形式 vs. vnext
出站接受 要么 简化形式(address、port、id、security ……),要么 完整的 vnext 形式。简化形式会被改写成单条 vnext 数组(infra/conf/vmess.go:121-129)。完整形式必须 恰好 一个服务器一个用户 —— 多端点请使用多个 VMess 出站加路由负载均衡器。
示例
最小入站:
json
{
"inbounds": [
{
"tag": "vmess-in",
"listen": "0.0.0.0",
"port": 443,
"protocol": "vmess",
"settings": {
"clients": [
{ "id": "a3482e88-686a-4a58-8126-99c9df64b7bf", "email": "alice", "security": "auto" }
]
},
"streamSettings": { "network": "tcp", "security": "tls" }
}
]
}简化出站:
json
{
"outbounds": [
{
"tag": "vmess-out",
"protocol": "vmess",
"settings": {
"address": "example.com",
"port": 443,
"id": "a3482e88-686a-4a58-8126-99c9df64b7bf",
"security": "auto"
},
"streamSettings": { "network": "ws", "security": "tls", "wsSettings": { "path": "/vm" } }
}
]
}说明
- Xray 的 VMess 只支持 AEAD。配置结构体里没有
alterId字段。 从带"alterId": <n>的 V2Ray 配置迁移过来时应当删除该字段;新版 客户端 / 服务端无论如何都会拒绝旧的 MD5-AEAD 模式。 security: "auto"是安全的默认值:在带 AES-NI 的平台选 AES-GCM, 其他平台选 ChaCha20-Poly1305。未知的security字符串会静默回退 到auto(infra/conf/vmess.go:37-38)。security: "zero"仅用于测试 —— 完全不做对称加密,只有握手提供 密码学保护。- 每次加载 VMess 入站或出站时都会打印启动期弃用横幅 ("VMess (with no Forward Secrecy, etc.)",
infra/conf/vmess.go:67, 118)。 推荐用带mlkem768x25519plus加密的 VLESS 替代。
跨内核说明
- sing-box 用
users[].uuid替代clients[].id,并暴露 Xray 已 不再支持的alter_id(snake_case)、global_padding、authenticated_length选项。参见 VMess — sing-box。 - mihomo 采用单一 proxy 对象形态,用
cipher字段表示加密选择, 并在出站上暴露 UDP 编码开关(xudp、packet-addr、packet-encoding)。参见 VMess — mihomo。
源码: infra/conf/vmess.go:18-124 · v26.6.1 (94ffd50)
