Fix nested rule-set match cache isolation
This commit is contained in:
@@ -101,6 +101,10 @@ type InboundContext struct {
|
|||||||
func (c *InboundContext) ResetRuleCache() {
|
func (c *InboundContext) ResetRuleCache() {
|
||||||
c.IPCIDRMatchSource = false
|
c.IPCIDRMatchSource = false
|
||||||
c.IPCIDRAcceptEmpty = false
|
c.IPCIDRAcceptEmpty = false
|
||||||
|
c.ResetRuleMatchCache()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *InboundContext) ResetRuleMatchCache() {
|
||||||
c.SourceAddressMatch = false
|
c.SourceAddressMatch = false
|
||||||
c.SourcePortMatch = false
|
c.SourcePortMatch = false
|
||||||
c.DestinationAddressMatch = false
|
c.DestinationAddressMatch = false
|
||||||
|
|||||||
@@ -41,10 +41,12 @@ func (r *RuleSetItem) Start() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *RuleSetItem) Match(metadata *adapter.InboundContext) bool {
|
func (r *RuleSetItem) Match(metadata *adapter.InboundContext) bool {
|
||||||
metadata.IPCIDRMatchSource = r.ipCidrMatchSource
|
|
||||||
metadata.IPCIDRAcceptEmpty = r.ipCidrAcceptEmpty
|
|
||||||
for _, ruleSet := range r.setList {
|
for _, ruleSet := range r.setList {
|
||||||
if ruleSet.Match(metadata) {
|
nestedMetadata := *metadata
|
||||||
|
nestedMetadata.ResetRuleMatchCache()
|
||||||
|
nestedMetadata.IPCIDRMatchSource = r.ipCidrMatchSource
|
||||||
|
nestedMetadata.IPCIDRAcceptEmpty = r.ipCidrAcceptEmpty
|
||||||
|
if ruleSet.Match(&nestedMetadata) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,7 +203,9 @@ func (s *LocalRuleSet) Close() error {
|
|||||||
|
|
||||||
func (s *LocalRuleSet) Match(metadata *adapter.InboundContext) bool {
|
func (s *LocalRuleSet) Match(metadata *adapter.InboundContext) bool {
|
||||||
for _, rule := range s.rules {
|
for _, rule := range s.rules {
|
||||||
if rule.Match(metadata) {
|
nestedMetadata := *metadata
|
||||||
|
nestedMetadata.ResetRuleMatchCache()
|
||||||
|
if rule.Match(&nestedMetadata) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -323,7 +323,9 @@ func (s *RemoteRuleSet) Close() error {
|
|||||||
|
|
||||||
func (s *RemoteRuleSet) Match(metadata *adapter.InboundContext) bool {
|
func (s *RemoteRuleSet) Match(metadata *adapter.InboundContext) bool {
|
||||||
for _, rule := range s.rules {
|
for _, rule := range s.rules {
|
||||||
if rule.Match(metadata) {
|
nestedMetadata := *metadata
|
||||||
|
nestedMetadata.ResetRuleMatchCache()
|
||||||
|
if rule.Match(&nestedMetadata) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user