github.com/kelleygo/clashcore@v1.0.2/constant/rule.go (about) 1 package constant 2 3 // Rule Type 4 const ( 5 Domain RuleType = iota 6 DomainSuffix 7 DomainKeyword 8 DomainRegex 9 GEOSITE 10 GEOIP 11 SrcGEOIP 12 IPASN 13 SrcIPASN 14 IPCIDR 15 SrcIPCIDR 16 IPSuffix 17 SrcIPSuffix 18 SrcPort 19 DstPort 20 InPort 21 DSCP 22 InUser 23 InName 24 InType 25 Process 26 ProcessPath 27 RuleSet 28 Network 29 Uid 30 SubRules 31 MATCH 32 AND 33 OR 34 NOT 35 ) 36 37 type RuleType int 38 39 func (rt RuleType) String() string { 40 switch rt { 41 case Domain: 42 return "Domain" 43 case DomainSuffix: 44 return "DomainSuffix" 45 case DomainKeyword: 46 return "DomainKeyword" 47 case DomainRegex: 48 return "DomainRegex" 49 case GEOSITE: 50 return "GeoSite" 51 case GEOIP: 52 return "GeoIP" 53 case SrcGEOIP: 54 return "SrcGeoIP" 55 case IPASN: 56 return "IPASN" 57 case SrcIPASN: 58 return "SrcIPASN" 59 case IPCIDR: 60 return "IPCIDR" 61 case SrcIPCIDR: 62 return "SrcIPCIDR" 63 case IPSuffix: 64 return "IPSuffix" 65 case SrcIPSuffix: 66 return "SrcIPSuffix" 67 case SrcPort: 68 return "SrcPort" 69 case DstPort: 70 return "DstPort" 71 case InPort: 72 return "InPort" 73 case InUser: 74 return "InUser" 75 case InName: 76 return "InName" 77 case InType: 78 return "InType" 79 case Process: 80 return "Process" 81 case ProcessPath: 82 return "ProcessPath" 83 case MATCH: 84 return "Match" 85 case RuleSet: 86 return "RuleSet" 87 case Network: 88 return "Network" 89 case DSCP: 90 return "DSCP" 91 case Uid: 92 return "Uid" 93 case SubRules: 94 return "SubRules" 95 case AND: 96 return "AND" 97 case OR: 98 return "OR" 99 case NOT: 100 return "NOT" 101 default: 102 return "Unknown" 103 } 104 } 105 106 type Rule interface { 107 RuleType() RuleType 108 Match(metadata *Metadata) (bool, string) 109 Adapter() string 110 Payload() string 111 ShouldResolveIP() bool 112 ShouldFindProcess() bool 113 }