Skip to content

Commit

Permalink
Fix SNAT never being added because of exception
Browse files Browse the repository at this point in the history
Some firewall rule object (iptc) do not have a parameter
attribute, which results in an exception being triggered,
and the mailcow SNAT rule to never be created.

Firewall rules that trigger such exception are:
- -A POSTROUTING -s 192.168.122.0/24 -d 224.0.0.0/24 -j RETURN

This commit just verify attribute presence, and skip the rule
properly instead of triggering an exception.
  • Loading branch information
brunoleon committed Feb 27, 2023
1 parent d20df7d commit f77c654
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions data/Dockerfiles/netfilter/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ def get_snat4_rule():
chain.insert_rule(new_rule)
else:
for position, rule in enumerate(chain.rules):
if not hasattr(rule.target, 'parameter'):
continue
match = all((
new_rule.get_src() == rule.get_src(),
new_rule.get_dst() == rule.get_dst(),
Expand Down

0 comments on commit f77c654

Please sign in to comment.