跳转至
编辑此页

提供者(proxy-providers、rule-providers、inbound-providers)

提供者用于从远程 HTTP、本地文件(支持操作系统文件监听自动热重载)或内联列表动态加载代理节点、路由规则和入站监听器。

所有本地文件与缓存 path 均相对 -d 解析,并受 安全路径 检查约束。


代理提供者(proxy-providers)

支持 http 与 file 两种类型(不支持 inline)。

type: http

YAML 键名 类型 必填 默认值 说明
type "http" 是 — 远程 HTTP 节点提供者。
url string 是 — 合法 HTTP(S) URL(直连拉取;未实现 proxy 与自定义 header 字段)。
path string 否 proxy_providers/<md5(url)>.yaml 本地缓存文件路径(相对 -d)。
interval u64(秒) 否 86400(24 小时) 定时拉取间隔(0 禁用定时刷新)。
health-check 对象 否 见下文 健康检查配置。

type: file

YAML 键名 类型 必填 默认值 说明
type "file" 是 — 本地文件节点提供者(自动开启文件系统监听,50 ms 防抖热重载)。
path string 是 — 本地 YAML 路径(相对 -d)。
interval u64(秒) 否 0(禁用轮询) 可选轮询间隔。
health-check 对象 否 见下文 健康检查配置。

health-check

YAML 键名 类型 默认值 说明
enable bool — 重要说明:当前运行时未读取 enable 字段;只要 interval != 0 就会执行自动健康检查。如需关闭自动测速,请显式设置 interval: 0。
url string "http://www.gstatic.com/generate_204" 测速地址。
interval u64(秒) 300 检测间隔(0 关闭自动检测)。
lazy bool true 是否仅在有流量使用时才测速。

提供者文件格式

内容必须是包含顶层 proxies: 列表的 YAML(单个解析失败的节点会记录警告并跳过,不影响其他节点):

providers/nodes.yaml
proxies:
  - name: hk-01
    type: ss
    server: hk01.example.com
    port: 8388
    cipher: aes-256-gcm
    password: "password"
config.yaml
proxy-providers:
  remote-sub:
    type: http
    url: "https://sub.example.com/proxies.yaml"
    path: ./providers/remote-sub.yaml
    interval: 3600
    health-check:
      enable: true
      url: http://www.gstatic.com/generate_204
      interval: 300
      lazy: true

  local-nodes:
    type: file
    path: ./providers/nodes.yaml
    health-check:
      interval: 0

未实现的 Mihomo proxy-providers 字段

proxy、header、filter、exclude-filter、exclude-type、override、payload、size-limit、dialer-proxy、health-check.expected-status、health-check.timeout 均未定义。


规则提供者(rule-providers)

支持 http、file 与 inline 三种类型,并在路由初始化时后台异步加载。

行为(behavior)与格式(format)

  • behavior(必填):
  • domain:构建为高效 DomainSet,支持精确域名、*.example.com(单级通配)、.example.com(仅子域)、+.example.com(自身及所有子域)。
  • ipcidr:构建为 IPv4/IPv6 CidrTrie。
  • classical:不带目标的常规规则列表(TYPE,PAYLOAD[,OPTIONS],不允许嵌套 RULE-SET),自动对 DOMAIN、DOMAIN-SUFFIX、DOMAIN-KEYWORD 与无 no-resolve 的 IP-CIDR 建立快速索引。
  • format(可选,默认 yaml):
  • yaml:包含 payload: [...] 列表的 YAML 对象。
  • text:按行分隔的纯文本(自动跳过空行及 # / // 注释行)。
  • mrs:Mihomo Rule Set v1 二进制格式(Zstandard 压缩,magic MRS\x01);仅支持 domain 与 ipcidr,classical 下报错。

各类型字段汇总

类型 必填字段 可选字段与默认值
http type: http、url、behavior interval(0)、path(rules/<md5(url)>)、format(yaml)、inline-rules / payload(在 yaml/text 下合并)
file type: file、path、behavior interval(无;使用系统文件监听热重载)、format(yaml)、inline-rules / payload(在 yaml/text 下合并)
inline type: inline、behavior、inline-rules(别名 payload) path(rules/<md5(name)>,运行时不用)
rule-providers:
  ad-domains:
    type: http
    behavior: domain
    format: mrs
    url: "https://rules.example.com/ads.mrs"
    path: ./rules/ads.mrs
    interval: 86400

  lan-cidrs:
    type: file
    behavior: ipcidr
    format: text
    path: ./rules/lan.txt

  custom-inline:
    type: inline
    behavior: classical
    payload:
      - DOMAIN-SUFFIX,internal.example.com
      - IP-CIDR,198.51.100.0/24,no-resolve

入站提供者(inbound-providers)

从本地文件或远程 HTTP 动态加载额外 listeners 列表,内容 YAML 需包含顶层 listeners: 字段。

类型 必填字段 可选字段与默认值
http type: http、url interval(86400 秒)、path(inbound_providers/<md5(url)>.yaml)
file type: file、path interval(0,禁用轮询;走文件监听)

对于 shadowsocks、anytls 与 hysteria2 监听器,修改提供者中的 users 列表会直接原地热更新用户凭据,不中断监听端口。

inbound-providers:
  server-users:
    type: file
    path: ./inbounds/users.yaml