Chore: embed the RuleExtra into Base

This commit is contained in:
yaling888
2022-03-13 01:21:23 +08:00
parent 8fbf93ccc8
commit 46b9a1092d
47 changed files with 1995 additions and 471 deletions

View File

@ -5,8 +5,8 @@ import (
)
type Match struct {
adapter string
ruleExtra *C.RuleExtra
*Base
adapter string
}
func (f *Match) RuleType() C.RuleType {
@ -29,16 +29,11 @@ func (f *Match) ShouldResolveIP() bool {
return false
}
func (f *Match) RuleExtra() *C.RuleExtra {
return f.ruleExtra
func NewMatch(adapter string) *Match {
return &Match{
Base: &Base{},
adapter: adapter,
}
}
func NewMatch(adapter string, ruleExtra *C.RuleExtra) *Match {
if ruleExtra.SourceIPs == nil {
ruleExtra = nil
}
return &Match{
adapter: adapter,
ruleExtra: ruleExtra,
}
}
var _ C.Rule = (*Match)(nil)