github.com/metacubex/mihomo@v1.18.5/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 ProcessName 26 ProcessPath 27 ProcessNameRegex 28 ProcessPathRegex 29 RuleSet 30 Network 31 Uid 32 SubRules 33 MATCH 34 AND 35 OR 36 NOT 37 ) 38 39 type RuleType int 40 41 func (rt RuleType) String() string { 42 switch rt { 43 case Domain: 44 return "Domain" 45 case DomainSuffix: 46 return "DomainSuffix" 47 case DomainKeyword: 48 return "DomainKeyword" 49 case DomainRegex: 50 return "DomainRegex" 51 case GEOSITE: 52 return "GeoSite" 53 case GEOIP: 54 return "GeoIP" 55 case SrcGEOIP: 56 return "SrcGeoIP" 57 case IPASN: 58 return "IPASN" 59 case SrcIPASN: 60 return "SrcIPASN" 61 case IPCIDR: 62 return "IPCIDR" 63 case SrcIPCIDR: 64 return "SrcIPCIDR" 65 case IPSuffix: 66 return "IPSuffix" 67 case SrcIPSuffix: 68 return "SrcIPSuffix" 69 case SrcPort: 70 return "SrcPort" 71 case DstPort: 72 return "DstPort" 73 case InPort: 74 return "InPort" 75 case InUser: 76 return "InUser" 77 case InName: 78 return "InName" 79 case InType: 80 return "InType" 81 case ProcessName: 82 return "ProcessName" 83 case ProcessPath: 84 return "ProcessPath" 85 case ProcessNameRegex: 86 return "ProcessNameRegex" 87 case ProcessPathRegex: 88 return "ProcessPathRegex" 89 case MATCH: 90 return "Match" 91 case RuleSet: 92 return "RuleSet" 93 case Network: 94 return "Network" 95 case DSCP: 96 return "DSCP" 97 case Uid: 98 return "Uid" 99 case SubRules: 100 return "SubRules" 101 case AND: 102 return "AND" 103 case OR: 104 return "OR" 105 case NOT: 106 return "NOT" 107 default: 108 return "Unknown" 109 } 110 } 111 112 type Rule interface { 113 RuleType() RuleType 114 Match(metadata *Metadata) (bool, string) 115 Adapter() string 116 Payload() string 117 ShouldResolveIP() bool 118 ShouldFindProcess() bool 119 }