fix: IDNA domain match

This commit is contained in:
Skyxim
2022-06-18 18:13:54 +08:00
parent bf55428954
commit c1a99b9be4
4 changed files with 33 additions and 19 deletions

View File

@ -1,6 +1,7 @@
package common
import (
"golang.org/x/net/idna"
"strings"
C "github.com/Dreamacro/clash/constant"
@ -8,8 +9,9 @@ import (
type DomainSuffix struct {
*Base
suffix string
adapter string
suffix string
adapter string
rawSuffix string
}
func (ds *DomainSuffix) RuleType() C.RuleType {
@ -29,14 +31,16 @@ func (ds *DomainSuffix) Adapter() string {
}
func (ds *DomainSuffix) Payload() string {
return ds.suffix
return ds.rawSuffix
}
func NewDomainSuffix(suffix string, adapter string) *DomainSuffix {
actualDomainKeyword, _ := idna.ToASCII(suffix)
return &DomainSuffix{
Base: &Base{},
suffix: strings.ToLower(suffix),
adapter: adapter,
Base: &Base{},
suffix: strings.ToLower(actualDomainKeyword),
adapter: adapter,
rawSuffix: suffix,
}
}