mihomo/rule/common/domain.go
gVisor bot f7759c1468 Merge remote-tracking branch 'clash/dev' into Alpha
# 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
2022-03-15 23:13:41 +08:00

52 lines
863 B
Go

package common
import (
"strings"
C "github.com/Dreamacro/clash/constant"
)
type Domain struct {
domain string
adapter string
ruleExtra *C.RuleExtra
}
func (d *Domain) RuleType() C.RuleType {
return C.Domain
}
func (d *Domain) Match(metadata *C.Metadata) bool {
if metadata.AddrType != C.AtypDomainName {
return false
}
return metadata.Host == d.domain
}
func (d *Domain) Adapter() string {
return d.adapter
}
func (d *Domain) Payload() string {
return d.domain
}
func (d *Domain) ShouldResolveIP() bool {
return false
}
func (d *Domain) RuleExtra() *C.RuleExtra {
return d.ruleExtra
}
func (d *Domain) ShouldFindProcess() bool {
return false
}
func NewDomain(domain string, adapter string, ruleExtra *C.RuleExtra) *Domain {
return &Domain{
domain: strings.ToLower(domain),
adapter: adapter,
ruleExtra: ruleExtra,
}
}