generated from TrueCloudLab/basic
engine: Simplify multiple chains processing #86
1 changed files with 9 additions and 14 deletions
|
@ -42,41 +42,36 @@ func (dr *defaultChainRouter) checkLocal(name chain.Name, rt RequestTarget, r re
|
||||||
if dr.local == nil {
|
if dr.local == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var ruleFounds []bool
|
|
||||||
|
var hasAllow bool
|
||||||
for _, target := range rt.Targets() {
|
for _, target := range rt.Targets() {
|
||||||
status, ruleFound, err = dr.matchLocalOverrides(name, target, r)
|
status, ruleFound, err = dr.matchLocalOverrides(name, target, r)
|
||||||
if err != nil || ruleFound && status != chain.Allow {
|
if err != nil || ruleFound && status != chain.Allow {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ruleFounds = append(ruleFounds, ruleFound)
|
hasAllow = hasAllow || ruleFound
|
||||||
}
|
}
|
||||||
|
|
||||||
status = chain.NoRuleFound
|
status = chain.NoRuleFound
|
||||||
for _, ruleFound = range ruleFounds {
|
if hasAllow {
|
||||||
if ruleFound {
|
status = chain.Allow
|
||||||
status = chain.Allow
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dr *defaultChainRouter) checkMorph(name chain.Name, rt RequestTarget, r resource.Request) (status chain.Status, ruleFound bool, err error) {
|
func (dr *defaultChainRouter) checkMorph(name chain.Name, rt RequestTarget, r resource.Request) (status chain.Status, ruleFound bool, err error) {
|
||||||
var ruleFounds []bool
|
var hasAllow bool
|
||||||
for _, target := range rt.Targets() {
|
for _, target := range rt.Targets() {
|
||||||
status, ruleFound, err = dr.matchMorphRuleChains(name, target, r)
|
status, ruleFound, err = dr.matchMorphRuleChains(name, target, r)
|
||||||
if err != nil || ruleFound && status != chain.Allow {
|
if err != nil || ruleFound && status != chain.Allow {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ruleFounds = append(ruleFounds, ruleFound)
|
hasAllow = hasAllow || ruleFound
|
||||||
}
|
}
|
||||||
|
|
||||||
status = chain.NoRuleFound
|
status = chain.NoRuleFound
|
||||||
for _, ruleFound = range ruleFounds {
|
if hasAllow {
|
||||||
if ruleFound {
|
status = chain.Allow
|
||||||
status = chain.Allow
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue