Skip to content

Commit

Permalink
split function
Browse files Browse the repository at this point in the history
  • Loading branch information
mlsmaycon committed Nov 23, 2024
1 parent d18b0a7 commit 78bd1dd
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions management/server/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,25 +421,32 @@ func (a *Account) getPeerRoutesFirewallRules(ctx context.Context, peerID string,

for _, accessGroup := range route.AccessControlGroups {
policies := getAllRoutePoliciesFromGroups(a, []string{accessGroup})
for _, policy := range policies {
if !policy.Enabled {
continue
}
rules := a.getRouteFirewallRules(ctx, peerID, policies, route, validatedPeersMap, distributionPeers)
routesFirewallRules = append(routesFirewallRules, rules...)
}
}

for _, rule := range policy.Rules {
if !rule.Enabled {
continue
}
return routesFirewallRules
}

rulePeers := a.getRulePeers(rule, peerID, distributionPeers, validatedPeersMap)
rules := generateRouteFirewallRules(ctx, route, rule, rulePeers, firewallRuleDirectionIN)
routesFirewallRules = append(routesFirewallRules, rules...)
}
func (a *Account) getRouteFirewallRules(ctx context.Context, peerID string, policies []*Policy, route *route.Route, validatedPeersMap map[string]struct{}, distributionPeers map[string]struct{}) []*RouteFirewallRule {
fwRules := make([]*RouteFirewallRule, 0)
for _, policy := range policies {
if !policy.Enabled {
continue
}

for _, rule := range policy.Rules {
if !rule.Enabled {
continue
}

rulePeers := a.getRulePeers(rule, peerID, distributionPeers, validatedPeersMap)
rules := generateRouteFirewallRules(ctx, route, rule, rulePeers, firewallRuleDirectionIN)
fwRules = append(fwRules, rules...)
}
}

return routesFirewallRules
return fwRules
}

func (a *Account) getRulePeers(rule *PolicyRule, peerID string, distributionPeers map[string]struct{}, validatedPeersMap map[string]struct{}) []*nbpeer.Peer {
Expand Down

0 comments on commit 78bd1dd

Please sign in to comment.