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
|
|
|
|
GEOIP
|
|
|
|
IPCIDR
|
2019-02-02 21:03:13 +08:00
|
|
|
SourceIPCIDR
|
2019-02-18 21:53:57 +08:00
|
|
|
MATCH
|
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"
|
|
|
|
case GEOIP:
|
|
|
|
return "GEOIP"
|
|
|
|
case IPCIDR:
|
|
|
|
return "IPCIDR"
|
2019-02-02 21:03:13 +08:00
|
|
|
case SourceIPCIDR:
|
|
|
|
return "SourceIPCIDR"
|
2019-02-18 21:53:57 +08:00
|
|
|
case MATCH:
|
|
|
|
return "MATCH"
|
2018-06-20 22:41:02 +08:00
|
|
|
default:
|
|
|
|
return "Unknow"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-10 22:50:03 +08:00
|
|
|
type Rule interface {
|
|
|
|
RuleType() RuleType
|
2018-09-30 12:25:52 +08:00
|
|
|
IsMatch(metadata *Metadata) bool
|
2018-06-10 22:50:03 +08:00
|
|
|
Adapter() string
|
2018-06-20 22:41:02 +08:00
|
|
|
Payload() string
|
2018-06-10 22:50:03 +08:00
|
|
|
}
|