feat: nameserver-policy
support use rule-providers and reduce domain-set memory
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"golang.org/x/net/idna"
|
||||
"strings"
|
||||
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
@ -11,7 +10,6 @@ type DomainSuffix struct {
|
||||
*Base
|
||||
suffix string
|
||||
adapter string
|
||||
isIDNA bool
|
||||
}
|
||||
|
||||
func (ds *DomainSuffix) RuleType() C.RuleType {
|
||||
@ -28,20 +26,14 @@ func (ds *DomainSuffix) Adapter() string {
|
||||
}
|
||||
|
||||
func (ds *DomainSuffix) Payload() string {
|
||||
suffix := ds.suffix
|
||||
if ds.isIDNA {
|
||||
suffix, _ = idna.ToUnicode(suffix)
|
||||
}
|
||||
return suffix
|
||||
return ds.suffix
|
||||
}
|
||||
|
||||
func NewDomainSuffix(suffix string, adapter string) *DomainSuffix {
|
||||
actualDomainSuffix, _ := idna.ToASCII(suffix)
|
||||
return &DomainSuffix{
|
||||
Base: &Base{},
|
||||
suffix: strings.ToLower(actualDomainSuffix),
|
||||
suffix: strings.ToLower(suffix),
|
||||
adapter: adapter,
|
||||
isIDNA: suffix != actualDomainSuffix,
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user