Skip to content

Commit 0e69462

Browse files
committed
Add set/get policy functions
1 parent 3eb7d23 commit 0e69462

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

iptc/easy.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,17 @@ def test_target(name, value, ipv6=False):
185185
return False
186186

187187

188+
def get_policy(table, chain, ipv6=False):
189+
""" Return the default policy of chain in a table """
190+
iptc_chain = _iptc_getchain(table, chain, ipv6)
191+
return iptc_chain.get_policy().name
192+
193+
def set_policy(table, chain, policy='ACCEPT', ipv6=False):
194+
""" Set the default policy of chain in a table """
195+
iptc_chain = _iptc_getchain(table, chain, ipv6)
196+
iptc_chain.set_policy(policy)
197+
198+
188199
def dump_all(ipv6=False):
189200
""" Return a dictionary representation of all tables """
190201
return {table: dump_table(table, ipv6) for table in get_tables(ipv6)}

0 commit comments

Comments
 (0)