Fix bug which may cause UnboundLocalError#271
Fix bug which may cause UnboundLocalError#271brianzf wants to merge 2 commits intoldx:masterfrom brianzf:master
Conversation
|
Can you elaborate? |
|
my code meet crash under such a context: input data code traceback |
|
iptables -L Chain INPUT (policy DROP) Chain FORWARD (policy ACCEPT) Chain OUTPUT (policy ACCEPT) |
|
iptables -t nat -L Chain PREROUTING (policy ACCEPT) Chain INPUT (policy ACCEPT) Chain OUTPUT (policy ACCEPT) Chain POSTROUTING (policy ACCEPT) |
|
commit a second time, hope useful |
|
Any chance you're using an old version? Can you try to install python-iptables from latest master, and give it a host? |
|
@brianzf , this python snippet works for me, can you test it ? server_nat_acl = ['5.5.5.0/24']
chain = iptc.Chain(iptc.Table(iptc.Table.NAT), "POSTROUTING")
for net in server_nat_acl:
rule = iptc.Rule()
#rule.protocol = "tcp"
#rule.out_interface = "eth0"
rule.dst = net
rule.create_target("MASQUERADE")
chain.insert_rule(rule)$ sudo iptables -t nat -S POSTROUTING
-P POSTROUTING ACCEPT
-A POSTROUTING -d 5.5.5.0/24 -j MASQUERADEBetter yet, you could use this |
|
Is this getting merged? I can't reliably reproduce it, but I ran into this traceback at some point: I don't know enough about the project to tell if the fix makes sense, but the logic in the current code is clearly wrong, as there are code paths where |
|
@guille That being said, it does not hurt to be more defensive against malformatted input. Let me rebase this change on top current master, so the tests will also pass. |
No description provided.