Skip to content

Commit

Permalink
[client] Fix acl empty port range detection (#3285)
Browse files Browse the repository at this point in the history
  • Loading branch information
lixmal authored Feb 5, 2025
1 parent 97d498c commit 125b5e2
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion client/internal/acl/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (d *DefaultManager) protoRuleToFirewallRule(
}

var port *firewall.Port
if r.PortInfo != nil {
if !portInfoEmpty(r.PortInfo) {
port = convertPortInfo(r.PortInfo)
} else if r.Port != "" {
// old version of management, single port
Expand Down Expand Up @@ -305,6 +305,22 @@ func (d *DefaultManager) protoRuleToFirewallRule(
return ruleID, rules, nil
}

func portInfoEmpty(portInfo *mgmProto.PortInfo) bool {
if portInfo == nil {
return true
}

switch portInfo.GetPortSelection().(type) {
case *mgmProto.PortInfo_Port:
return portInfo.GetPort() == 0
case *mgmProto.PortInfo_Range_:
r := portInfo.GetRange()
return r == nil || r.Start == 0 || r.End == 0
default:
return true
}
}

func (d *DefaultManager) addInRules(
ip net.IP,
protocol firewall.Protocol,
Expand Down

0 comments on commit 125b5e2

Please sign in to comment.