github.com/igoogolx/clash@v1.19.8/constant/rule.go (about) 1 package constant 2 3 const ( 4 RuleConfigDomain RuleConfig = "DOMAIN" 5 RuleConfigDomainSuffix RuleConfig = "DOMAIN-SUFFIX" 6 RuleConfigDomainKeyword RuleConfig = "DOMAIN-KEYWORD" 7 RuleConfigGeoIP RuleConfig = "GEOIP" 8 RuleConfigIPCIDR RuleConfig = "IP-CIDR" 9 RuleConfigIPCIDR6 RuleConfig = "IP-CIDR6" 10 RuleConfigSrcIPCIDR RuleConfig = "SRC-IP-CIDR" 11 RuleConfigSrcPort RuleConfig = "SRC-PORT" 12 RuleConfigDstPort RuleConfig = "DST-PORT" 13 RuleConfigInboundPort RuleConfig = "INBOUND-PORT" 14 RuleConfigProcessName RuleConfig = "PROCESS-NAME" 15 RuleConfigProcessPath RuleConfig = "PROCESS-PATH" 16 RuleConfigIPSet RuleConfig = "IPSET" 17 RuleConfigRuleSet RuleConfig = "RULE-SET" 18 RuleConfigScript RuleConfig = "SCRIPT" 19 RuleConfigMatch RuleConfig = "MATCH" 20 ) 21 22 // Rule Config Type String represents a rule type in configuration files. 23 type RuleConfig string 24 25 // Rule Type 26 const ( 27 Domain RuleType = iota 28 DomainSuffix 29 DomainKeyword 30 GEOIP 31 IPCIDR 32 SrcIPCIDR 33 SrcPort 34 DstPort 35 InboundPort 36 Process 37 ProcessPath 38 IPSet 39 MATCH 40 ) 41 42 type RuleType int 43 44 func (rt RuleType) String() string { 45 switch rt { 46 case Domain: 47 return "Domain" 48 case DomainSuffix: 49 return "DomainSuffix" 50 case DomainKeyword: 51 return "DomainKeyword" 52 case GEOIP: 53 return "GeoIP" 54 case IPCIDR: 55 return "IPCIDR" 56 case SrcIPCIDR: 57 return "SrcIPCIDR" 58 case SrcPort: 59 return "SrcPort" 60 case DstPort: 61 return "DstPort" 62 case InboundPort: 63 return "InboundPort" 64 case Process: 65 return "Process" 66 case ProcessPath: 67 return "ProcessPath" 68 case IPSet: 69 return "IPSet" 70 case MATCH: 71 return "Match" 72 default: 73 return "Unknown" 74 } 75 } 76 77 type Rule interface { 78 RuleType() RuleType 79 Match(metadata *Metadata) bool 80 Adapter() string 81 Payload() string 82 ShouldResolveIP() bool 83 ShouldFindProcess() bool 84 }