clash/constant/rule.go

43 lines
607 B
Go
Raw Normal View History

2018-06-10 14:50:03 +00:00
package constant
// Rule Type
const (
2018-09-09 07:01:46 +00:00
Domain RuleType = iota
DomainSuffix
2018-06-10 14:50:03 +00:00
DomainKeyword
GEOIP
IPCIDR
SourceIPCIDR
2018-06-10 14:50:03 +00:00
FINAL
)
type RuleType int
2018-06-20 14:41:02 +00:00
func (rt RuleType) String() string {
switch rt {
2018-09-09 07:01:46 +00:00
case Domain:
return "Domain"
2018-06-20 14:41:02 +00:00
case DomainSuffix:
return "DomainSuffix"
case DomainKeyword:
return "DomainKeyword"
case GEOIP:
return "GEOIP"
case IPCIDR:
return "IPCIDR"
case SourceIPCIDR:
return "SourceIPCIDR"
2018-06-20 14:41:02 +00:00
case FINAL:
return "FINAL"
default:
return "Unknow"
}
}
2018-06-10 14:50:03 +00:00
type Rule interface {
RuleType() RuleType
2018-09-30 04:25:52 +00:00
IsMatch(metadata *Metadata) bool
2018-06-10 14:50:03 +00:00
Adapter() string
2018-06-20 14:41:02 +00:00
Payload() string
2018-06-10 14:50:03 +00:00
}