Fix: Remove EnableProcess from config.go and enable-process from config.yaml.

Fix: FindProcess is now enabled by default when the rule set contains process-name rules.
This commit is contained in:
Larvan2
2023-01-20 16:29:08 +08:00
parent 5bbf73e3b5
commit 8a7027e8d6
10 changed files with 36 additions and 17 deletions

View File

@ -42,6 +42,11 @@ func (c *classicalStrategy) OnUpdate(rules []string) {
shouldResolveIP := false
for _, rawRule := range rules {
ruleType, rule, params := ruleParse(rawRule)
if ruleType == "PROCESS-NAME" {
c.shouldFindProcess = true
}
r, err := c.parse(ruleType, rule, "", params)
if err != nil {
log.Warnln("parse rule error:[%s]", err.Error())

View File

@ -12,6 +12,10 @@ type domainStrategy struct {
domainRules *trie.DomainTrie[struct{}]
}
func (d *domainStrategy) ShouldFindProcess() bool {
return false
}
func (d *domainStrategy) Match(metadata *C.Metadata) bool {
return d.domainRules != nil && d.domainRules.Search(metadata.Host) != nil
}

View File

@ -12,6 +12,10 @@ type ipcidrStrategy struct {
trie *trie.IpCidrTrie
}
func (i *ipcidrStrategy) ShouldFindProcess() bool {
return false
}
func (i *ipcidrStrategy) Match(metadata *C.Metadata) bool {
return i.trie != nil && i.trie.IsContain(metadata.DstIP.AsSlice())
}

View File

@ -37,6 +37,7 @@ type ruleStrategy interface {
Match(metadata *C.Metadata) bool
Count() int
ShouldResolveIP() bool
ShouldFindProcess() bool
OnUpdate(rules []string)
}
@ -86,6 +87,10 @@ func (rp *ruleSetProvider) ShouldResolveIP() bool {
return rp.strategy.ShouldResolveIP()
}
func (rp *ruleSetProvider) ShouldFindProcess() bool {
return rp.strategy.ShouldFindProcess()
}
func (rp *ruleSetProvider) AsRule(adaptor string) C.Rule {
panic("implement me")
}

View File

@ -9,14 +9,15 @@ import (
type RuleSet struct {
*common.Base
ruleProviderName string
adapter string
ruleProvider P.RuleProvider
noResolveIP bool
ruleProviderName string
adapter string
ruleProvider P.RuleProvider
noResolveIP bool
shouldFindProcess bool
}
func (rs *RuleSet) ShouldFindProcess() bool {
return false
return !rs.shouldFindProcess && rs.getProviders().ShouldFindProcess()
}
func (rs *RuleSet) RuleType() C.RuleType {