mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-15 21:51:23 +08:00
f01ac69654
# Conflicts: # .github/workflows/codeql-analysis.yml # .github/workflows/docker.yml # .github/workflows/linter.yml # .github/workflows/stale.yml # Makefile # component/dialer/dialer.go # config/config.go # constant/metadata.go # constant/rule.go # rule/common/domain.go # rule/common/domain_keyword.go # rule/common/domain_suffix.go # rule/common/final.go # rule/common/ipcidr.go # rule/geoip.go # rule/parser.go # rule/port.go # rule/process.go
55 lines
1009 B
Go
55 lines
1009 B
Go
package common
|
|
|
|
import (
|
|
"strings"
|
|
|
|
C "github.com/Dreamacro/clash/constant"
|
|
)
|
|
|
|
type DomainSuffix struct {
|
|
suffix string
|
|
adapter string
|
|
ruleExtra *C.RuleExtra
|
|
}
|
|
|
|
func (ds *DomainSuffix) RuleType() C.RuleType {
|
|
return C.DomainSuffix
|
|
}
|
|
|
|
func (ds *DomainSuffix) Match(metadata *C.Metadata) bool {
|
|
if metadata.AddrType != C.AtypDomainName {
|
|
return false
|
|
}
|
|
domain := metadata.Host
|
|
return strings.HasSuffix(domain, "."+ds.suffix) || domain == ds.suffix
|
|
}
|
|
|
|
func (ds *DomainSuffix) Adapter() string {
|
|
return ds.adapter
|
|
}
|
|
|
|
func (ds *DomainSuffix) Payload() string {
|
|
return ds.suffix
|
|
}
|
|
|
|
func (ds *DomainSuffix) ShouldResolveIP() bool {
|
|
return false
|
|
}
|
|
|
|
func (ds *DomainSuffix) RuleExtra() *C.RuleExtra {
|
|
return ds.ruleExtra
|
|
}
|
|
|
|
|
|
func (ds *DomainSuffix) ShouldFindProcess() bool {
|
|
return false
|
|
}
|
|
|
|
func NewDomainSuffix(suffix string, adapter string, ruleExtra *C.RuleExtra) *DomainSuffix {
|
|
return &DomainSuffix{
|
|
suffix: strings.ToLower(suffix),
|
|
adapter: adapter,
|
|
ruleExtra: ruleExtra,
|
|
}
|
|
}
|