fix: remove extra and the actual original IDNA domain name is no longer stored, for reduce memory

This commit is contained in:
Skyxim
2022-08-11 21:50:16 +08:00
parent 93ea1248e3
commit 473d0f74bd
7 changed files with 37 additions and 131 deletions

View File

@@ -9,9 +9,9 @@ import (
type DomainKeyword struct {
*Base
keyword string
adapter string
rawKeyword string
keyword string
adapter string
isIDNA bool
}
func (dk *DomainKeyword) RuleType() C.RuleType {
@@ -31,16 +31,20 @@ func (dk *DomainKeyword) Adapter() string {
}
func (dk *DomainKeyword) Payload() string {
return dk.rawKeyword
keyword := dk.keyword
if dk.isIDNA {
keyword, _ = idna.ToUnicode(keyword)
}
return keyword
}
func NewDomainKeyword(keyword string, adapter string) *DomainKeyword {
actualDomainKeyword, _ := idna.ToASCII(keyword)
return &DomainKeyword{
Base: &Base{},
keyword: strings.ToLower(actualDomainKeyword),
adapter: adapter,
rawKeyword: keyword,
Base: &Base{},
keyword: strings.ToLower(actualDomainKeyword),
adapter: adapter,
isIDNA: keyword != actualDomainKeyword,
}
}