Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com>
This commit is contained in:
bcmmbaga 2025-06-18 21:46:21 +03:00
parent db9f55d31a
commit 56f35628f4
No known key found for this signature in database
GPG Key ID: 511EED5C928AD547

View File

@ -1055,7 +1055,7 @@ func (a *Account) connResourcesGenerator(ctx context.Context, targetPeer *nbpeer
continue continue
} }
rules = append(rules, expandPortsAndRanges(ctx, fr, rule, targetPeer)...) rules = append(rules, expandPortsAndRanges(fr, rule, targetPeer)...)
} }
}, func() ([]*nbpeer.Peer, []*FirewallRule) { }, func() ([]*nbpeer.Peer, []*FirewallRule) {
return peers, rules return peers, rules
@ -1586,7 +1586,7 @@ func (a *Account) AddAllGroup() error {
} }
// expandPortsAndRanges expands Ports and PortRanges of a rule into individual firewall rules // expandPortsAndRanges expands Ports and PortRanges of a rule into individual firewall rules
func expandPortsAndRanges(ctx context.Context, base FirewallRule, rule *PolicyRule, peer *nbpeer.Peer) []*FirewallRule { func expandPortsAndRanges(base FirewallRule, rule *PolicyRule, peer *nbpeer.Peer) []*FirewallRule {
var expanded []*FirewallRule var expanded []*FirewallRule
if len(rule.Ports) > 0 { if len(rule.Ports) > 0 {
@ -1600,9 +1600,8 @@ func expandPortsAndRanges(ctx context.Context, base FirewallRule, rule *PolicyRu
var peerSupportsPortRanges bool var peerSupportsPortRanges bool
// skip processing the port ranges if the peer version doesn't support it meetMinVer, err := posture.MeetsMinVersion(firewallRuleMinPortRangesVer, peer.Meta.WtVersion)
meetMin, err := posture.MeetsMinVersion(firewallRuleMinPortRangesVer, peer.Meta.WtVersion) if err == nil && meetMinVer {
if err == nil && meetMin {
peerSupportsPortRanges = true peerSupportsPortRanges = true
} }
@ -1618,7 +1617,6 @@ func expandPortsAndRanges(ctx context.Context, base FirewallRule, rule *PolicyRu
} }
fr.Port = strconv.FormatUint(uint64(portRange.Start), 10) fr.Port = strconv.FormatUint(uint64(portRange.Start), 10)
} }
expanded = append(expanded, &fr) expanded = append(expanded, &fr)
} }