github.com/chwjbn/xclash@v0.2.0/constant/rule.go (about)

     1  package constant
     2  
     3  // Rule Type
     4  const (
     5  	Domain RuleType = iota
     6  	DomainSuffix
     7  	DomainKeyword
     8  	GEOIP
     9  	IPCIDR
    10  	SrcIPCIDR
    11  	SrcPort
    12  	DstPort
    13  	Process
    14  	MATCH
    15  )
    16  
    17  type RuleType int
    18  
    19  func (rt RuleType) String() string {
    20  	switch rt {
    21  	case Domain:
    22  		return "Domain"
    23  	case DomainSuffix:
    24  		return "DomainSuffix"
    25  	case DomainKeyword:
    26  		return "DomainKeyword"
    27  	case GEOIP:
    28  		return "GeoIP"
    29  	case IPCIDR:
    30  		return "IPCIDR"
    31  	case SrcIPCIDR:
    32  		return "SrcIPCIDR"
    33  	case SrcPort:
    34  		return "SrcPort"
    35  	case DstPort:
    36  		return "DstPort"
    37  	case Process:
    38  		return "Process"
    39  	case MATCH:
    40  		return "Match"
    41  	default:
    42  		return "Unknown"
    43  	}
    44  }
    45  
    46  type Rule interface {
    47  	RuleType() RuleType
    48  	Match(metadata *Metadata) bool
    49  	Adapter() string
    50  	Payload() string
    51  	ShouldResolveIP() bool
    52  }