mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-06 08:22:38 +07:00
fix: problem that cannot use unsorted ip set in dns response routing
This commit is contained in:
@ -12,7 +12,6 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/v2rayA/ahocorasick-domain"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -185,7 +184,6 @@ func (n *AhocorasickSlimtrie) Build() (err error) {
|
||||
continue
|
||||
}
|
||||
toBuild = ToSuffixTrieStrings(toBuild)
|
||||
sort.Strings(toBuild)
|
||||
n.trie[i], err = trie.NewTrie(toBuild, ValidDomainChars)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -143,7 +143,7 @@ func ParamParser(to reflect.Value, section *config_parser.Section, ignoreType []
|
||||
// Assign. "to" should have field "Rules".
|
||||
structField, ok := to.Type().FieldByName("Rules")
|
||||
if !ok || structField.Type != reflect.TypeOf([]*config_parser.RoutingRule{}) {
|
||||
return fmt.Errorf("unexpected type: \"routing rule\": %v", itemVal.String(true, false, false))
|
||||
return fmt.Errorf("cannot use routing rule in this context: %v", itemVal.String(true, false, false))
|
||||
}
|
||||
if structField.Tag.Get("mapstructure") != "_" {
|
||||
return fmt.Errorf("a []*RoutingRule field \"Rules\" with mapstructure:\"_\" is required in struct %v to parse section", to.Type().String())
|
||||
|
@ -5,8 +5,10 @@ package trie
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/daeuniverse/dae/common"
|
||||
"github.com/daeuniverse/dae/common/bitlist"
|
||||
"math/bits"
|
||||
"sort"
|
||||
)
|
||||
|
||||
type ValidChars struct {
|
||||
@ -86,8 +88,9 @@ type Trie struct {
|
||||
|
||||
// NewTrie creates a new *Trie struct, from a slice of sorted strings.
|
||||
func NewTrie(keys []string, chars *ValidChars) (*Trie, error) {
|
||||
|
||||
// Check chars.
|
||||
keys = common.Deduplicate(keys)
|
||||
sort.Strings(keys)
|
||||
for _, key := range keys {
|
||||
for _, c := range []byte(key) {
|
||||
if !chars.IsValidChar(c) {
|
||||
|
Reference in New Issue
Block a user