feat: ruleset support text format

This commit is contained in:
wwqgtxx
2023-04-14 13:51:26 +08:00
parent b3794ffdd8
commit e4926c8364
3 changed files with 97 additions and 45 deletions

View File

@ -73,17 +73,27 @@ type ProxyProvider interface {
Version() uint32
}
// Rule Type
// RuleProvider interface
type RuleProvider interface {
Provider
Behavior() RuleBehavior
Match(*constant.Metadata) bool
ShouldResolveIP() bool
ShouldFindProcess() bool
AsRule(adaptor string) constant.Rule
}
// Rule Behavior
const (
Domain RuleType = iota
Domain RuleBehavior = iota
IPCIDR
Classical
)
// RuleType defined
type RuleType int
// RuleBehavior defined
type RuleBehavior int
func (rt RuleType) String() string {
func (rt RuleBehavior) String() string {
switch rt {
case Domain:
return "Domain"
@ -96,12 +106,20 @@ func (rt RuleType) String() string {
}
}
// RuleProvider interface
type RuleProvider interface {
Provider
Behavior() RuleType
Match(*constant.Metadata) bool
ShouldResolveIP() bool
ShouldFindProcess() bool
AsRule(adaptor string) constant.Rule
const (
YamlRule RuleFormat = iota
TextRule
)
type RuleFormat int
func (rf RuleFormat) String() string {
switch rf {
case YamlRule:
return "YamlRule"
case TextRule:
return "TextRule"
default:
return "Unknown"
}
}