From 5d3915c751e7acbbfa5ad7d844d1431078e9e80e Mon Sep 17 00:00:00 2001 From: Huang-Huang Bao Date: Sat, 7 May 2022 02:01:05 +0800 Subject: [PATCH] Fix: build routing condition for geo domain --- app/router/config.go | 12 ++++++++++++ app/router/router.go | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/router/config.go b/app/router/config.go index 88149caae..cc8032856 100644 --- a/app/router/config.go +++ b/app/router/config.go @@ -46,6 +46,18 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) { conds.Add(cond) } + var geoDomains []*routercommon.Domain + for _, geo := range rr.GeoDomain { + geoDomains = append(geoDomains, geo.Domain...) + } + if len(geoDomains) > 0 { + cond, err := NewDomainMatcher(rr.DomainMatcher, geoDomains) + if err != nil { + return nil, newError("failed to build geo domain condition").Base(err) + } + conds.Add(cond) + } + if len(rr.UserEmail) > 0 { conds.Add(NewUserMatcher(rr.UserEmail)) } diff --git a/app/router/router.go b/app/router/router.go index 051c54dfa..9dca59a4f 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -220,7 +220,6 @@ func init() { if err != nil { return nil, newError("unable to load geodomain").Base(err) } - rule.Domain = append(rule.Domain, geo.Domain...) } } if v.PortList != "" { @@ -240,6 +239,7 @@ func init() { rule.SourcePortList = portList.Build() } rule.Domain = v.Domain + rule.GeoDomain = v.GeoDomain if v.Networks != "" { rule.Networks = net.ParseNetworks(v.Networks) }