mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 19:56:51 +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
53 lines
863 B
Go
53 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,
|
|
}
|
|
}
|