Clash.Meta/constant/rule.go

120 lines
1.7 KiB
Go
Raw Normal View History

2018-06-10 22:50:03 +08:00
package constant
// Rule Type
const (
2018-09-09 15:01:46 +08:00
Domain RuleType = iota
DomainSuffix
2018-06-10 22:50:03 +08:00
DomainKeyword
2024-03-07 23:32:07 +08:00
DomainRegex
2021-11-17 16:03:47 +08:00
GEOSITE
2018-06-10 22:50:03 +08:00
GEOIP
SrcGEOIP
2024-03-12 03:14:25 +08:00
IPASN
SrcIPASN
IPCIDR
2019-05-09 21:00:29 +08:00
SrcIPCIDR
IPSuffix
SrcIPSuffix
2019-05-09 21:00:29 +08:00
SrcPort
DstPort
2022-11-11 23:36:06 +08:00
InPort
DSCP
InUser
InName
InType
ProcessName
ProcessPath
ProcessNameRegex
ProcessPathRegex
2021-12-02 22:56:17 +08:00
RuleSet
Network
Uid
SubRules
2019-02-18 21:53:57 +08:00
MATCH
AND
OR
NOT
2018-06-10 22:50:03 +08:00
)
type RuleType int
2018-06-20 22:41:02 +08:00
func (rt RuleType) String() string {
switch rt {
2018-09-09 15:01:46 +08:00
case Domain:
return "Domain"
2018-06-20 22:41:02 +08:00
case DomainSuffix:
return "DomainSuffix"
case DomainKeyword:
return "DomainKeyword"
2024-03-07 23:32:07 +08:00
case DomainRegex:
return "DomainRegex"
2021-11-17 16:03:47 +08:00
case GEOSITE:
return "GeoSite"
2018-06-20 22:41:02 +08:00
case GEOIP:
return "GeoIP"
case SrcGEOIP:
return "SrcGeoIP"
2024-03-12 03:14:25 +08:00
case IPASN:
return "IPASN"
case SrcIPASN:
return "SrcIPASN"
case IPCIDR:
return "IPCIDR"
2019-05-09 21:00:29 +08:00
case SrcIPCIDR:
return "SrcIPCIDR"
case IPSuffix:
return "IPSuffix"
case SrcIPSuffix:
return "SrcIPSuffix"
2019-05-09 21:00:29 +08:00
case SrcPort:
return "SrcPort"
case DstPort:
return "DstPort"
2022-11-11 23:36:06 +08:00
case InPort:
return "InPort"
case InUser:
return "InUser"
case InName:
return "InName"
case InType:
return "InType"
case ProcessName:
return "ProcessName"
case ProcessPath:
return "ProcessPath"
case ProcessNameRegex:
return "ProcessNameRegex"
case ProcessPathRegex:
return "ProcessPathRegex"
2019-02-18 21:53:57 +08:00
case MATCH:
return "Match"
2021-12-02 22:56:17 +08:00
case RuleSet:
return "RuleSet"
case Network:
return "Network"
case DSCP:
return "DSCP"
case Uid:
return "Uid"
case SubRules:
return "SubRules"
case AND:
return "AND"
case OR:
return "OR"
case NOT:
return "NOT"
2018-06-20 22:41:02 +08:00
default:
2019-08-26 12:26:14 +08:00
return "Unknown"
2018-06-20 22:41:02 +08:00
}
}
2018-06-10 22:50:03 +08:00
type Rule interface {
RuleType() RuleType
Match(metadata *Metadata) (bool, string)
2018-06-10 22:50:03 +08:00
Adapter() string
2018-06-20 22:41:02 +08:00
Payload() string
ShouldResolveIP() bool
ShouldFindProcess() bool
2018-06-10 22:50:03 +08:00
}