出站
outbounds 是上游目标的数组。每个条目都是扁平对象:type / tag 信封加上所选类型自身的字段,处于同一层级。没有"第一个出站即默认"的规则 — 未命中的流量走 route.final。
信封
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
type | string | — | direct | block | selector | urltest | socks | http | shadowsocks | vmess | trojan | naive | tor | ssh | shadowtls | vless | anytls | hysteria | tuic | hysteria2 | 出站类型。决定对象其余部分解码到哪个选项结构体。未注册的值会在启动时报 "unknown outbound type"。 |
tag | string | — | — | 该出站的唯一名称。被路由规则、route.final、组出站与拨号 detour 引用。 |
源码: option/outbound.go:19-23 · 锚定版本 v1.13.15 (3708fa1)
各类型字段见协议页面:Direct、HTTP 与 SOCKS、Shadowsocks、VMess、Trojan、Naive、Tor、SSH、VLESS、AnyTLS、Hysteria2、TUIC。selector 与 urltest 是在其他 tag 之间选择的组出站。
共享拨号字段(DialerOptions)
每个进行拨号的出站都内嵌 DialerOptions;这些字段与信封处于同一扁平层级。
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
detour | string | — | — | 通过另一个出站(按其 tag 寻址)拨号。 |
bind_interface | string | — | — | 出站连接绑定的网络接口。 |
inet4_bind_address | *badoption.Addr | — | — | 绑定的 IPv4 源地址。 |
inet6_bind_address | *badoption.Addr | — | — | 绑定的 IPv6 源地址。 |
bind_address_no_port | bool | false | true | false | 绑定时设置 IP_BIND_ADDRESS_NO_PORT — 将端口分配推迟到 connect。仅 Linux。 |
protect_path | string | — | — | Android VpnService protect 守护进程的 Unix 套接字路径;每个套接字 fd 在拨号前都会先送到那里。 |
routing_mark | FwMark | — | — | 在出站套接字上设置的 SO_MARK(fwmark)。仅 Linux。 |
reuse_addr | bool | false | true | false | 在出站套接字上设置 SO_REUSEADDR。 |
netns | string | — | — | 拨号所在的网络命名空间(名称或路径)。仅 Linux。 |
connect_timeout | badoption.Duration | — | — | TCP 连接超时。时长字符串,如 "5s"。 |
tcp_fast_open | bool | false | true | false | 为出站连接启用 TCP Fast Open。 |
tcp_multi_path | bool | false | true | false | 为出站连接启用 Multipath TCP。 |
disable_tcp_keep_alive | bool | false | true | false | 对出站连接关闭 TCP keep-alive。 |
tcp_keep_alive | badoption.Duration | — | — | 开始发送探测前的 keep-alive 空闲时长。时长字符串。 |
tcp_keep_alive_interval | badoption.Duration | — | — | keep-alive 探测之间的间隔。时长字符串。 |
udp_fragment | *bool | false | true | false | 允许分片超过 MTU 的 UDP 数据包,而不是丢弃。 |
domain_resolver | *DomainResolveOptions | — | — | 用哪个 DNS 服务器(按 tag)解析服务器地址:纯 tag 字符串,或带每次拨号覆盖项的对象。 |
network_strategy | *NetworkStrategy | — | — | 在可用网络之间选择的策略(如 default / hybrid / fallback)。仅具备网络感知的平台构建。 |
network_type | badoption.Listable[InterfaceType] | — | — | 使用 network_strategy 时偏好的网络类型(wifi、cellular、ethernet、other)。 |
fallback_network_type | badoption.Listable[InterfaceType] | — | — | 偏好的网络不可用时回退到的网络类型。 |
fallback_delay | badoption.Duration | — | — | 启动回退拨号前的等待时间(Happy-Eyeballs 风格)。时长字符串,如 "300ms"。 |
domain_strategy | DomainStrategy | — | prefer_ipv4 | prefer_ipv6 | ipv4_only | ipv6_only | 解析服务器域名时的地址族策略。 |
源码: option/outbound.go:67-93 · 锚定版本 v1.13.15 (3708fa1)
共享服务器字段(ServerOptions)
连接固定服务器的协议出站内嵌 ServerOptions。
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
server | string | — | — | 服务器主机名或 IP。 |
server_port | uint16 | — | — | 服务器端口。 |
源码: option/outbound.go:148-151 · 锚定版本 v1.13.15 (3708fa1)
最简示例
json
{
"outbounds": [
{
"type": "shadowsocks",
"tag": "proxy",
"server": "example.com",
"server_port": 8388,
"method": "2022-blake3-aes-128-gcm",
"password": "<base64-key>"
},
{ "type": "direct", "tag": "direct" }
],
"route": { "final": "proxy" }
}说明
dns出站在 1.11.0 废弃并在 1.13.0 移除 — 配置它会报错;DNS 劫持现在是 rule action。wireguard出站同样已移除:改用 WireGuard 端点。shadowsocksr仅注册为报错的占位(1.6.0 移除)。hysteria、tuic、hysteria2与naive出站需要with_quic构建(官方发布的二进制包含它)。detour按 tag 链接出站;链路回到自身是启动错误。- 当
server是域名时,解析遵循domain_resolver/domain_strategy;未配置时采用路由的默认 DNS。
跨内核说明
- Xray-core 把协议字段嵌套在
settings中,用proxySettings做链式代理,并把数组第一个条目作为默认路由目标。见 Xray 出站。 - mihomo 把它们称作
proxies,组类型(select、url-test、fallback、load-balance)是独立的代理组,而不是出站类型。
源码: option/outbound.go:19-23 · v1.13.15 (3708fa1)
