From cd588d017d3a155137c2ac1960aa5c8c0477f16c Mon Sep 17 00:00:00 2001 From: mzz2017 <2017@duck.com> Date: Sun, 19 Feb 2023 00:11:30 +0800 Subject: [PATCH] optimize: even faster domain keyword matching --- component/routing/domain_matcher/ahocorasick_slimtrie.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/component/routing/domain_matcher/ahocorasick_slimtrie.go b/component/routing/domain_matcher/ahocorasick_slimtrie.go index dabb6bb..e746b97 100644 --- a/component/routing/domain_matcher/ahocorasick_slimtrie.go +++ b/component/routing/domain_matcher/ahocorasick_slimtrie.go @@ -111,7 +111,7 @@ func (n *AhocorasickSlimtrie) MatchDomainBitmap(domain string) (bitmap []uint32) // Already matched. continue } - if hits := n.ac[i].MatchThreadSafe([]byte(domain)); len(hits) > 0 { + if n.ac[i].Contains([]byte(domain)) { bitmap[i/32] |= 1 << (i % 32) } } diff --git a/go.mod b/go.mod index 02bdd88..6486538 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/safchain/ethtool v0.0.0-20230116090318-67cc41908669 github.com/sirupsen/logrus v1.9.0 github.com/spf13/cobra v1.6.1 - github.com/v2rayA/ahocorasick-domain v0.0.0-20230218133743-71484cb9a7a1 + github.com/v2rayA/ahocorasick-domain v0.0.0-20230218160829-122a074c48c8 github.com/v2rayA/dae-config-dist/go/dae_config v0.0.0-20230201041341-1758ee5161c1 github.com/vishvananda/netlink v1.1.0 github.com/x-cray/logrus-prefixed-formatter v0.5.2 diff --git a/go.sum b/go.sum index ed63f3c..b50e20f 100644 --- a/go.sum +++ b/go.sum @@ -132,8 +132,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/v2rayA/ahocorasick-domain v0.0.0-20230218133743-71484cb9a7a1 h1:9rmVkH/MsdM/NLLY9r7wqCP/zNbwTijGjwCyR88PbyA= -github.com/v2rayA/ahocorasick-domain v0.0.0-20230218133743-71484cb9a7a1/go.mod h1:mWch8I826zic/bKaCyE9ZZbWtFgEW0ox3EQ0NGm5DGw= +github.com/v2rayA/ahocorasick-domain v0.0.0-20230218160829-122a074c48c8 h1:2Liq3JvM/acVQZ7Gq9U5PpznMzlFRPYMPQxC2yXSi74= +github.com/v2rayA/ahocorasick-domain v0.0.0-20230218160829-122a074c48c8/go.mod h1:mWch8I826zic/bKaCyE9ZZbWtFgEW0ox3EQ0NGm5DGw= github.com/v2rayA/dae-config-dist/go/dae_config v0.0.0-20230201041341-1758ee5161c1 h1:Ke91ZtZItOO8/SK8nhZ1tXfXcUxj4Meq5pET/L9bHII= github.com/v2rayA/dae-config-dist/go/dae_config v0.0.0-20230201041341-1758ee5161c1/go.mod h1:JiTWeZybOkBfCqv/fy5jbFhXTxuLlyrI76gRNazz2sU= github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0=