VLESS — sing-box
sing-box 提供与 Xray 客户端 / 服务端互通的 VLESS 实现,支持握手后 快路径的 XTLS Vision,并在出站侧支持 XUDP 以承载 UDP-over-TLS 多路 复用。
入站
type: "vless" 入站:
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
users | []VLESSUser | [] | <VLESSUser array> | 可接受的用户列表。入站接受连接至少需要一个条目。 |
multiplex | *InboundMultiplexOptions | (disabled) | InboundMultiplexOptions | 服务端多路复用(smux / yamux / h2mux)。完整字段集合见多路复用页。 |
transport | *V2RayTransportOptions | (plain TCP) | V2RayTransportOptions | 可选的 V2Ray 风格传输层包装:ws、http、grpc、quic、hysteria。完整字段集合见传输层页。 |
源码: option/vless.go:3-9 · 锚定版本 v1.13.11 (553cfa1)
该结构体还内嵌 ListenOptions(监听地址、端口、嗅探、set 等)与 InboundTLSOptionsContainer(TLS 凭据)。这些是所有入站共享的块, 分别见入站页与 TLS 页。
users[]
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
name | string | (unset) | <string> | 用户显示名;用于统计 / 日志标签。 |
uuid | string | (required) | <UUID> | 用户 UUID。必填。规范的 8-4-4-4-12 形式。 |
flow | string | (empty) | | xtls-rprx-vision | 单用户 flow 算法。空 = 普通 VLESS;`xtls-rprx-vision` 启用 Vision。 |
源码: option/vless.go:11-15 · 锚定版本 v1.13.11 (553cfa1)
出站
type: "vless" 出站:
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
uuid | string | (required) | <UUID> | 上游服务器接受的用户 UUID。 |
flow | string | (empty) | | xtls-rprx-vision | flow 算法;必须与服务端期望一致。 |
network | NetworkList | (tcp+udp) | tcp | udp | <empty for both> | 限定为仅 TCP 或仅 UDP。空值同时启用两者。 |
multiplex | *OutboundMultiplexOptions | (disabled) | OutboundMultiplexOptions | 客户端多路复用。必须与服务端的多路复用配置一致。 |
transport | *V2RayTransportOptions | (plain TCP) | V2RayTransportOptions | V2Ray 风格传输层(ws、http、grpc 等)。 |
packet_encoding | *string | (unset) | packetaddr | xudp | 在 VLESS 流中承载 UDP 包的编码方式。`xudp` 与 Xray 的 XUDP 兼容;`packetaddr` 是较旧的单流形式。 |
源码: option/vless.go:17-27 · 锚定版本 v1.13.11 (553cfa1)
该结构体内嵌 DialerOptions(绑定接口、路由 mark、detour 等)、 ServerOptions(server、server_port)与 OutboundTLSOptionsContainer(tls)。
示例
单用户启用 XTLS Vision 的入站:
json
{
"inbounds": [
{
"type": "vless",
"tag": "vless-in",
"listen": "::",
"listen_port": 443,
"users": [
{ "name": "alice", "uuid": "a3482e88-686a-4a58-8126-99c9df64b7bf", "flow": "xtls-rprx-vision" }
],
"tls": {
"enabled": true,
"server_name": "example.com",
"certificate_path": "/etc/ssl/cert.pem",
"key_path": "/etc/ssl/key.pem"
}
}
]
}走 REALITY、UDP 经 XUDP 的出站:
json
{
"outbounds": [
{
"type": "vless",
"tag": "proxy",
"server": "example.com",
"server_port": 443,
"uuid": "a3482e88-686a-4a58-8126-99c9df64b7bf",
"flow": "xtls-rprx-vision",
"packet_encoding": "xudp",
"tls": {
"enabled": true,
"server_name": "www.google.com",
"utls": { "enabled": true, "fingerprint": "chrome" },
"reality": { "enabled": true, "public_key": "...", "short_id": "..." }
}
}
]
}说明
- sing-box 的 VLESS 服务端使用
users[].uuid,而非 Xray 的clients[].id。同一份 UUID 在两端通用,只是 JSON 键不同。 - sing-box 不支持 Xray 的 VLESS
fallbacks机制;等价行为由 共享tls块上的fallback字段提供(在 TLS 握手不匹配时转发)。 packet_encoding的可选值来自上游proxy/vless/packetaddr。xudp是现代默认值,与 Xray 在flow含-udp443后缀时使用 的编码一致。users[].flow与「无 flow」可以并存:没有 Vision 用户的服务端仍 可在同一端口接受普通 VLESS 客户端。
跨内核说明
- Xray 使用
clients[].id(UUID),且入站支持fallbacks数组。参见 VLESS — Xray-core。 - mihomo 把所有信息打包到单个 proxy 对象(出站没有独立的
users数组)。参见 VLESS — mihomo。
源码: option/vless.go:3-27 · v1.13.11 (553cfa1)
