[client] Apply return traffic rules only if firewall is stateless (#3895)

This commit is contained in:
Viktor Liu
2025-06-02 12:11:54 +02:00
committed by GitHub
parent f16f0c7831
commit 41cd4952f1
7 changed files with 130 additions and 83 deletions

View File

@@ -285,8 +285,10 @@ func (d *DefaultManager) protoRuleToFirewallRule(
case mgmProto.RuleDirection_IN:
rules, err = d.addInRules(r.PolicyID, ip, protocol, port, action, ipsetName)
case mgmProto.RuleDirection_OUT:
// TODO: Remove this soon. Outbound rules are obsolete.
// We only maintain this for return traffic (inbound dir) which is now handled by the stateful firewall already
if d.firewall.IsStateful() {
return "", nil, nil
}
// return traffic for outbound connections if firewall is stateless
rules, err = d.addOutRules(r.PolicyID, ip, protocol, port, action, ipsetName)
default:
return "", nil, fmt.Errorf("invalid direction, skipping firewall rule")