mirror of
https://github.com/daeuniverse/dae.git
synced 2024-12-22 20:34:40 +07:00
fix(routing): Fix MergeAndSortRulesOptimizer (#682)
This commit is contained in:
parent
438c05cbd6
commit
334cbd3962
@ -7,15 +7,16 @@ package routing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/netip"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/daeuniverse/dae/common/assets"
|
"github.com/daeuniverse/dae/common/assets"
|
||||||
"github.com/daeuniverse/dae/common/consts"
|
"github.com/daeuniverse/dae/common/consts"
|
||||||
"github.com/daeuniverse/dae/pkg/config_parser"
|
"github.com/daeuniverse/dae/pkg/config_parser"
|
||||||
"github.com/daeuniverse/dae/pkg/geodata"
|
"github.com/daeuniverse/dae/pkg/geodata"
|
||||||
"github.com/mohae/deepcopy"
|
"github.com/mohae/deepcopy"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"net/netip"
|
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type RulesOptimizer interface {
|
type RulesOptimizer interface {
|
||||||
@ -87,6 +88,7 @@ func (o *MergeAndSortRulesOptimizer) Optimize(rules []*config_parser.RoutingRule
|
|||||||
if len(mergingRule.AndFunctions) == 1 &&
|
if len(mergingRule.AndFunctions) == 1 &&
|
||||||
len(rules[i].AndFunctions) == 1 &&
|
len(rules[i].AndFunctions) == 1 &&
|
||||||
mergingRule.AndFunctions[0].Name == rules[i].AndFunctions[0].Name &&
|
mergingRule.AndFunctions[0].Name == rules[i].AndFunctions[0].Name &&
|
||||||
|
mergingRule.AndFunctions[0].Not == rules[i].AndFunctions[0].Not &&
|
||||||
rules[i].Outbound.String(true, false, true) == mergingRule.Outbound.String(true, false, true) {
|
rules[i].Outbound.String(true, false, true) == mergingRule.Outbound.String(true, false, true) {
|
||||||
mergingRule.AndFunctions[0].Params = append(mergingRule.AndFunctions[0].Params, rules[i].AndFunctions[0].Params...)
|
mergingRule.AndFunctions[0].Params = append(mergingRule.AndFunctions[0].Params, rules[i].AndFunctions[0].Params...)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user