Replies: 5 comments
-
Refactoring
|
Beta Was this translation helpful? Give feedback.
-
Please file a PR. |
Beta Was this translation helpful? Give feedback.
-
Refactoring
|
Beta Was this translation helpful? Give feedback.
-
Refactoring
|
Beta Was this translation helpful? Give feedback.
-
(Draft) eTLD Index MatcherThe The eTLD Index Matcher: Data StructureThe domain string is split into three parts:
eTLD Index Matcher: Match AlgorithmDomain Matcher: Break the domain into three parts when adding the matcher:
Substr Matcher: Use AC Automata. Regex Matcher: Use simple matcher entry array. Full Matcher: Consider two cases:
|
Beta Was this translation helpful? Give feedback.
-
Port mph string matcher to DNS domain matching
I really appreciate @darsvador ‘s work in #587, #639, #743, and am impressed by its design and performance improvement. So I would like to port this string matcher to DNS module and use v2ray as the main DNS server in my asuswrt router's private network, since from source code dnsmasq seems to traverse all domains linearly without optimization, hence may suffering from both cpu and memory bottleneck when working in a router and scaling to things like domain-list-community.
Some modifications have to be done for
MphMatcherGroup
to properly work in DNS module. This is becauseMphMatcherGroup
is implemented as a "boolean" matcher:MphMatcherGroup.Match
only returns a 1-element array with the only value1
, while the DNS module expects theIndexMatcher
to work in this way:Matcher
(full, domain, substr or regex) from a specific domain rule bound to a DNS server.IndexMatcher
by callingAdd()
and gets a returned index.IndexMatcher.Match
and gets a list of indices.Therefore, the
IndexMatcher.Match
should have following guarantees for DNS module:Add(matcher)
's return value.To provide first guarantee for
IndexMatcher
, I plan to append additional fields forMphMatcherGroup
andACAutomata
:values
field of type[][]uint32
forMphMatcherGroup
, for each indexn
corrsponding tog.rules[n]
, there is a value arrayg.values[n]
. Value array is used here because the same rule can be added multiple times from different DNS servers.values
field of type[][]uint32
forACAutomata
, for each matched noden
, there is a value arrayac.values[n]
corresponding to the indices of the matchers (maybe further operations needed for different match type?).@darsvador How much do you think these fields would affect the memory efficiency of mph matcher?
To provide second guarantee for
IndexMatcher
, I plan to refactorMphMatcherGroup.Match
, as well asstrmatcher
package:IndexMatcher
should be refactored to add anAdd
method, with the matching result's priority stablized as a specification inIndexMatcher
interface.MphMatcherGroup
's performance in routing matching, we may add a boolean flagfirstMatchOnly
to early return on first match.Beta Was this translation helpful? Give feedback.
All reactions