Skip to content

Conversation

@k9982874
Copy link
Contributor

@k9982874 k9982874 commented Mar 12, 2025

Remote Ruleset新增Dialer支持,允许Remote Ruleset像outbound一样覆盖default_domain_resolver的设置

起因:

一般情况下default_domain_resolver可以满足ruleset的解析,但是当使用一些内部私有地址时,在公共服务器上无法正确解析
下面是个例子,此时private-ruleset无法正确下载,因为https://example.com并不能被dns_ali正确解析

{
  "dns": {
    "servers": [ "dns_ali" ]
  },
  "route": {
    "default_domain_resolver": {
      "server": "dns_ali"
    },
    ...
    "rule_set": [
      {
        "tag": "private-ruleset",
        "type": "remote",
        "format": "source",
        "url": "https://example.com/something.json",
        "download_detour": "DIRECT-OUT"
      }
    ]
  }

解决方案:

给Remote Ruleset添加dialer支持,在进行下载Ruleset文件时,如果设置了domain_resolver将覆盖default_domain_resolver,以用户设置进行解析。行为上与outbound在配置domain_resolver时一致。
下面是个例子,此时private-ruleset将使用dns_private进行解析,而public-ruleset则继续走原有规则使用dns_ali进行解析

{
  "dns": {
    "servers": [
      "dns_ali",
      "dns_private"
    ]
  },
  "route": {
    "default_domain_resolver": {
      "server": "dns_ali"
    },
    ...
    "rule_set": [
      {
        "tag": "private-ruleset",
        "type": "remote",
        "format": "source",
        "url": "https://example.com/something.json",
        "detour": "PRIVATE-OUT",
        "domain_resolver": "dns_private"
      },
      {
        "tag": "public-ruleset",
        "type": "remote",
        "format": "source",
        "url": "A valid public URL",
      }
    ]
  }

受影响的现有逻辑:

保留了download_detour字段,在detour字段为空,download_detour字段内容有效时,使用download_detour的值
在detour字段和download_detour字段内容都有效时,优先使用detour的值

为什么不直接设置default_domain_resolver为私有dns?

因为私有dns使用了sing-box作为上游解析代理的情况下,有可能形成回环

@nekohasekai nekohasekai force-pushed the dev-next branch 13 times, most recently from e6856a6 to be2635b Compare December 30, 2025 19:20
@nekohasekai nekohasekai force-pushed the dev-next branch 6 times, most recently from fae949a to 1ee0b39 Compare January 7, 2026 10:46
@nekohasekai nekohasekai force-pushed the dev-next branch 6 times, most recently from 643057e to 5f4eee9 Compare January 15, 2026 02:42
@nekohasekai nekohasekai force-pushed the dev-next branch 5 times, most recently from 237887d to 5d67c13 Compare January 17, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants