5 # TODO escape shell commands more securely
7 return repr(text.encode('utf-8'))
9 def optional(switch, value):
11 return '%s %s' % (switch, s(value))
16 /usr/sbin/iptables -t filter -F
18 % for (index, rule) in enumerate(rules):
19 /usr/sbin/iptables -t filter \
20 -I ${rule.chain|s} ${index+1|s} \
22 ${optional('-s', rule.src)} \
23 ${optional('-d', rule.dst)} \
24 ${optional('-p', rule.protocol)} \
25 ${optional('-m', rule.protocol)} \
26 ${optional('--sport', rule.src_port)} \
27 ${optional('--dport', rule.dst_port)}
31 <%doc> vim: set filetype=python sw=4 sts=4 et : </%doc>