From 448debd620fea302e1cdc0c6bde1b792a6f347c6 Mon Sep 17 00:00:00 2001 From: mzz2017 <2017@duck.com> Date: Sun, 12 Feb 2023 11:17:10 +0800 Subject: [PATCH] feat: support no group filter --- component/outbound/filter.go | 5 +++++ config/config.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/component/outbound/filter.go b/component/outbound/filter.go index 94265d7..be83788 100644 --- a/component/outbound/filter.go +++ b/component/outbound/filter.go @@ -51,6 +51,11 @@ func NewDialerSetFromLinks(option *dialer.GlobalOption, tagToNodeList map[string } func (s *DialerSet) filterHit(dialer *dialer.Dialer, filters []*config_parser.Function) (hit bool, err error) { + if len(filters) == 0 { + // No filter. + return true, nil + } + // Example // filter: name(regex:'^.*hk.*$', keyword:'sg') && name(keyword:'disney') // filter: !name(regex: 'HK|TW|SG') && name(keyword: disney) diff --git a/config/config.go b/config/config.go index b6ca01c..a2b0fdd 100644 --- a/config/config.go +++ b/config/config.go @@ -32,7 +32,7 @@ type Group struct { } type GroupParam struct { - Filter []*config_parser.Function `mapstructure:"filter" required:""` + Filter []*config_parser.Function `mapstructure:"filter"` Policy interface{} `mapstructure:"policy" required:""` }