Skip to content

服务

services 运行既非入站也非出站的后台组件:systemd-resolved 替代品、Shadowsocks 服务器管理 API、Tailscale DERP 中继,以及若干运维辅助组件。条目形状与配置中其他位置一致 — 扁平的 type / tag 信封加上所选类型自身的字段,处于同一层级。

信封

字段类型默认值允许值描述
typestringresolved | ssm-api | derp | ccm | ocm | oom-killer服务类型。决定对象其余部分解码到哪个选项结构体。部分类型只存在于带相应标签的构建中 — 见说明。
tagstring该服务的唯一名称,用于日志行。

源码: option/service.go:16-20 · 锚定版本 v1.13.15 (3708fa1)

服务类型

类型运行内容
resolvedsystemd-resolved 的直接替代品:DNS 存根监听器(默认 127.0.0.53:53),通过 sing-box DNS 应答。与 resolved DNS 服务器类型配对使用。
ssm-apiShadowsocks Server Management API — 在运行中的 Shadowsocks 入站上创建、移除用户的 HTTP 端点。
derp内嵌的 Tailscale DERP 中继服务器。见 Tailscale
ccm / ocm / oom-killer面向嵌入式与移动端部署的运维辅助组件(连接/对象管理、内存不足保护)。

最简示例

json
{
  "services": [
    {
      "type": "resolved",
      "tag": "resolved",
      "listen": "127.0.0.53",
      "listen_port": 53
    }
  ]
}

说明

  • resolved 内嵌与入站相同的 ListenOptions;省略时 listen 默认 127.0.0.53listen_port 默认 53
  • ssm-api 接受一个 servers 映射(路径 → Shadowsocks 入站 tag)和可选的 cache_path
  • 构建标签决定可用性:derp 需要 with_tailscaleccm 需要 with_ccmocm 需要 with_ocmresolvedssm-apioom-killer 始终编译在内。
  • 未注册的 type 会在启动时报 "unknown service type"。

跨内核说明

  • Xray-core 没有服务列表;最接近的对应物是 APIMetrics 块,它们从专门的配置键生成管理监听器。
  • mihomo 通过外部控制器暴露管理能力,而不是可配置的后台服务。

源码: option/service.go:16-20 · v1.13.15 (3708fa1)

由 Argsment 出品的 Core Tutorial