mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
Accept "any" outbound in dns rule
This commit is contained in:
parent
88fafd4e30
commit
879c38351b
@ -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…
x
Reference in New Issue
Block a user