fix: cannot route for sniffed domain with port (#542)

Co-authored-by: Sumire (菫) <151038614+sumire88@users.noreply.github.com>
This commit is contained in:
mzz
2024-06-16 14:47:02 +08:00
committed by GitHub
parent e6bb146593
commit df76e0d6b9
5 changed files with 25 additions and 9 deletions

View File

@ -100,11 +100,12 @@ func (n *AhocorasickSlimtrie) MatchDomainBitmap(domain string) (bitmap []uint32)
bitmap = make([]uint32, N)
domain = strings.ToLower(strings.TrimSuffix(domain, "."))
// Domain should consist of 'a'-'z' and '.' and '-'
for _, b := range []byte(domain) {
if !ahocorasick.IsValidChar(b) {
return bitmap
}
}
// NOTE: DO NOT VERIFY THE DOMAIN TO MATCH: https://github.com/daeuniverse/dae/issues/528
// for _, b := range []byte(domain) {
// if !ahocorasick.IsValidChar(b) {
// return bitmap
// }
// }
// Suffix matching.
suffixTrieDomain := ToSuffixTrieString("^" + domain)
for _, i := range n.validTrieIndexes {

View File

@ -6,11 +6,12 @@
package domain_matcher
import (
"math/rand"
"testing"
"github.com/daeuniverse/dae/common/consts"
"github.com/sirupsen/logrus"
"golang.org/x/exp/slices"
"math/rand"
"testing"
)
func TestAhocorasickSlimtrie(t *testing.T) {