mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 07:03:23 +08:00
chore: Introducing Punycode conversion for domain matching
This commit is contained in:
parent
56ed9019a6
commit
f3743fc7f9
@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
|
||||
C "github.com/metacubex/mihomo/constant"
|
||||
"golang.org/x/net/idna"
|
||||
)
|
||||
|
||||
type Domain struct {
|
||||
@ -29,9 +30,10 @@ func (d *Domain) Payload() string {
|
||||
}
|
||||
|
||||
func NewDomain(domain string, adapter string) *Domain {
|
||||
punycode, _ := idna.ToASCII(strings.ToLower(domain))
|
||||
return &Domain{
|
||||
Base: &Base{},
|
||||
domain: strings.ToLower(domain),
|
||||
domain: punycode,
|
||||
adapter: adapter,
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
|
||||
C "github.com/metacubex/mihomo/constant"
|
||||
"golang.org/x/net/idna"
|
||||
)
|
||||
|
||||
type DomainKeyword struct {
|
||||
@ -30,9 +31,10 @@ func (dk *DomainKeyword) Payload() string {
|
||||
}
|
||||
|
||||
func NewDomainKeyword(keyword string, adapter string) *DomainKeyword {
|
||||
punycode, _ := idna.ToASCII(strings.ToLower(keyword))
|
||||
return &DomainKeyword{
|
||||
Base: &Base{},
|
||||
keyword: strings.ToLower(keyword),
|
||||
keyword: punycode,
|
||||
adapter: adapter,
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
|
||||
C "github.com/metacubex/mihomo/constant"
|
||||
"golang.org/x/net/idna"
|
||||
)
|
||||
|
||||
type DomainSuffix struct {
|
||||
@ -30,9 +31,10 @@ func (ds *DomainSuffix) Payload() string {
|
||||
}
|
||||
|
||||
func NewDomainSuffix(suffix string, adapter string) *DomainSuffix {
|
||||
punycode, _ := idna.ToASCII(strings.ToLower(suffix))
|
||||
return &DomainSuffix{
|
||||
Base: &Base{},
|
||||
suffix: strings.ToLower(suffix),
|
||||
suffix: punycode,
|
||||
adapter: adapter,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user