sing-box
sing-box copied to clipboard
Add dialer options for remote ruleset
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作为上游解析代理的情况下,有可能形成回环