github.com/igoogolx/clash@v1.19.8/rule/domain.go (about)

     1  package rules
     2  
     3  import (
     4  	"strings"
     5  
     6  	C "github.com/igoogolx/clash/constant"
     7  )
     8  
     9  // Implements C.Rule
    10  var _ C.Rule = (*Domain)(nil)
    11  
    12  type Domain struct {
    13  	domain  string
    14  	adapter string
    15  }
    16  
    17  func (d *Domain) RuleType() C.RuleType {
    18  	return C.Domain
    19  }
    20  
    21  func (d *Domain) Match(metadata *C.Metadata) bool {
    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 (d *Domain) ShouldFindProcess() bool {
    38  	return false
    39  }
    40  
    41  func NewDomain(domain string, adapter string) *Domain {
    42  	return &Domain{
    43  		domain:  strings.ToLower(domain),
    44  		adapter: adapter,
    45  	}
    46  }