mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-18 08:16:39 +00:00
[management] Enable unidirectional rules for all port policy (#3826)
This commit is contained in:
@@ -255,23 +255,12 @@ func (h *handler) savePolicy(w http.ResponseWriter, r *http.Request, accountID s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate policy object
|
// validate policy object
|
||||||
switch pr.Protocol {
|
if pr.Protocol == types.PolicyRuleProtocolALL || pr.Protocol == types.PolicyRuleProtocolICMP {
|
||||||
case types.PolicyRuleProtocolALL, types.PolicyRuleProtocolICMP:
|
|
||||||
if len(pr.Ports) != 0 || len(pr.PortRanges) != 0 {
|
if len(pr.Ports) != 0 || len(pr.PortRanges) != 0 {
|
||||||
util.WriteError(r.Context(), status.Errorf(status.InvalidArgument, "for ALL or ICMP protocol ports is not allowed"), w)
|
util.WriteError(r.Context(), status.Errorf(status.InvalidArgument, "for ALL or ICMP protocol ports is not allowed"), w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !pr.Bidirectional {
|
|
||||||
util.WriteError(r.Context(), status.Errorf(status.InvalidArgument, "for ALL or ICMP protocol type flow can be only bi-directional"), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
case types.PolicyRuleProtocolTCP, types.PolicyRuleProtocolUDP:
|
|
||||||
if !pr.Bidirectional && (len(pr.Ports) == 0 || len(pr.PortRanges) != 0) {
|
|
||||||
util.WriteError(r.Context(), status.Errorf(status.InvalidArgument, "for ALL or ICMP protocol type flow can be only bi-directional"), w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
policy.Rules = append(policy.Rules, &pr)
|
policy.Rules = append(policy.Rules, &pr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user