github.com/chwjbn/xclash@v0.2.0/rule/domain.go (about) 1 package rules 2 3 import ( 4 "strings" 5 6 C "github.com/chwjbn/xclash/constant" 7 ) 8 9 type Domain struct { 10 domain string 11 adapter string 12 } 13 14 func (d *Domain) RuleType() C.RuleType { 15 return C.Domain 16 } 17 18 func (d *Domain) Match(metadata *C.Metadata) bool { 19 if metadata.AddrType != C.AtypDomainName { 20 return false 21 } 22 return metadata.Host == d.domain 23 } 24 25 func (d *Domain) Adapter() string { 26 return d.adapter 27 } 28 29 func (d *Domain) Payload() string { 30 return d.domain 31 } 32 33 func (d *Domain) ShouldResolveIP() bool { 34 return false 35 } 36 37 func NewDomain(domain string, adapter string) *Domain { 38 return &Domain{ 39 domain: strings.ToLower(domain), 40 adapter: adapter, 41 } 42 }