1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-03 15:55:20 -05:00

Add minimal perfect hash domain matcher (#743)

* rename to HybridDomainMatcher & convert domain to lowercase

* refactor code & add open hashing for rolling hash map

* fix lint errors

* update app/dns/dns.go

* convert domain to lowercase in `strmatcher.go`

* keep the original matcher behavior

* add mph domain matcher & conver domain names to loweercase when matching

* fix lint errors

* fix lint errors
This commit is contained in:
DarthVader
2021-03-15 15:21:38 +08:00
committed by GitHub
parent e46204f828
commit ac1e5cd925
5 changed files with 308 additions and 104 deletions

View File

@@ -68,8 +68,8 @@ type DomainMatcher struct {
matchers strmatcher.IndexMatcher
}
func NewACAutomatonDomainMatcher(domains []*Domain) (*DomainMatcher, error) {
g := strmatcher.NewACAutomatonMatcherGroup()
func NewMphMatcherGroup(domains []*Domain) (*DomainMatcher, error) {
g := strmatcher.NewMphMatcherGroup()
for _, d := range domains {
matcherType, f := matcherTypeMap[d.Type]
if !f {
@@ -102,7 +102,7 @@ func NewDomainMatcher(domains []*Domain) (*DomainMatcher, error) {
}
func (m *DomainMatcher) ApplyDomain(domain string) bool {
return len(m.matchers.Match(domain)) > 0
return len(m.matchers.Match(strings.ToLower(domain))) > 0
}
// Apply implements Condition.