python-iptables
python-iptables copied to clipboard
Rule not added to chain.rules when created by using iptc.Rule(chain=chain), bug?
I notice that chain.rules have no rule that is created with iptc.Rule(chain=chain), I know we can add a rule by: chain.insert_rule(rule) but its not like it should be there already? If not why Rule() accept chain argument?
In [1]: import iptc
...: table = iptc.Table("nat")
...: chain = iptc.Chain(table, "PREROUTING")
...: rule = iptc.Rule(chain=chain)
...: print(chain, rule.chain)
...: print(chain.rules, rule)
print_1:
<iptc.ip4tc.Chain object at 0x7f0cdb351390> <iptc.ip4tc.Chain object at 0x7f0cdb351390>
print_2:
[
<iptc.ip4tc.Rule object at 0x7f0cdb351400>,
<iptc.ip4tc.Rule object at 0x7f0cd86d3550>,
<iptc.ip4tc.Rule object at 0x7f0cd86d3710>,
<iptc.ip4tc.Rule object at 0x7f0cd86d3860>
]
<iptc.ip4tc.Rule object at 0x7f0cdb351668>