mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-25 10:01:30 +00:00
Accept "any" outbound in dns rule
This commit is contained in:
parent
88fafd4e30
commit
b3fb86d415
|
@ -232,6 +232,8 @@ Invert match result.
|
||||||
|
|
||||||
Match outbound.
|
Match outbound.
|
||||||
|
|
||||||
|
`any` can be used as a value to match any outbound.
|
||||||
|
|
||||||
#### server
|
#### server
|
||||||
|
|
||||||
==Required==
|
==Required==
|
||||||
|
@ -255,17 +257,3 @@ Disable cache and save cache in this query.
|
||||||
#### rules
|
#### rules
|
||||||
|
|
||||||
Included default rules.
|
Included default rules.
|
||||||
|
|
||||||
#### invert
|
|
||||||
|
|
||||||
Invert match result.
|
|
||||||
|
|
||||||
#### server
|
|
||||||
|
|
||||||
==Required==
|
|
||||||
|
|
||||||
Tag of the target dns server.
|
|
||||||
|
|
||||||
#### disable_cache
|
|
||||||
|
|
||||||
Disable cache and save cache in this query.
|
|
|
@ -231,6 +231,8 @@ DNS 查询类型。值可以为整数或者类型名称字符串。
|
||||||
|
|
||||||
匹配出站。
|
匹配出站。
|
||||||
|
|
||||||
|
`any` 可作为值用于匹配任意出站。
|
||||||
|
|
||||||
#### server
|
#### server
|
||||||
|
|
||||||
==必填==
|
==必填==
|
||||||
|
@ -254,17 +256,3 @@ DNS 查询类型。值可以为整数或者类型名称字符串。
|
||||||
#### rules
|
#### rules
|
||||||
|
|
||||||
包括的默认规则。
|
包括的默认规则。
|
||||||
|
|
||||||
#### invert
|
|
||||||
|
|
||||||
反选匹配结果。
|
|
||||||
|
|
||||||
#### server
|
|
||||||
|
|
||||||
==必填==
|
|
||||||
|
|
||||||
目标 DNS 服务器的标签。
|
|
||||||
|
|
||||||
#### disable_cache
|
|
||||||
|
|
||||||
在此查询中禁用缓存。
|
|
|
@ -23,7 +23,10 @@
|
||||||
"disable_cache": true
|
"disable_cache": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"domain": "mydomain.com",
|
"outbound": "any",
|
||||||
|
"server": "local"
|
||||||
|
},
|
||||||
|
{
|
||||||
"geosite": "cn",
|
"geosite": "cn",
|
||||||
"server": "local"
|
"server": "local"
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,17 +12,25 @@ var _ RuleItem = (*OutboundItem)(nil)
|
||||||
type OutboundItem struct {
|
type OutboundItem struct {
|
||||||
outbounds []string
|
outbounds []string
|
||||||
outboundMap map[string]bool
|
outboundMap map[string]bool
|
||||||
|
matchAny bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewOutboundRule(outbounds []string) *OutboundItem {
|
func NewOutboundRule(outbounds []string) *OutboundItem {
|
||||||
rule := &OutboundItem{outbounds, make(map[string]bool)}
|
rule := &OutboundItem{outbounds: outbounds, outboundMap: make(map[string]bool)}
|
||||||
for _, outbound := range outbounds {
|
for _, outbound := range outbounds {
|
||||||
rule.outboundMap[outbound] = true
|
if outbound == "any" {
|
||||||
|
rule.matchAny = true
|
||||||
|
} else {
|
||||||
|
rule.outboundMap[outbound] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return rule
|
return rule
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *OutboundItem) Match(metadata *adapter.InboundContext) bool {
|
func (r *OutboundItem) Match(metadata *adapter.InboundContext) bool {
|
||||||
|
if r.matchAny && metadata.Outbound != "" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
return r.outboundMap[metadata.Outbound]
|
return r.outboundMap[metadata.Outbound]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue