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 % for (index, rule) in enumerate(rules):
17 /sbin/iptables -t filter \
18 -I ${rule.chain|s} ${index+1|s} \
20 ${optional('-s', rule.src)} \
21 ${optional('-d', rule.dst)} \
22 ${optional('-p', rule.protocol)} \
23 ${optional('-m', rule.protocol)} \
24 ${optional('--sport', rule.src_port)} \
25 ${optional('--dport', rule.dst_port)}
29 <%doc> vim: set filetype=python sw=4 sts=4 et : </%doc>