iptables.py: completely replace ipt script.

Doing it in python instead of shell makes the code a bit less error prone.
Plus we can parse the iptables output and avoid triggering iptables errors.
This commit is contained in:
Avery Pennarun
2010-05-01 21:30:59 -04:00
parent 8278dcfb5d
commit ad459e2918
4 changed files with 65 additions and 41 deletions

View File

@ -8,7 +8,7 @@ import options, client, iptables
def parse_subnets(subnets_str):
subnets = []
for s in subnets_str:
m = re.match(r'(\d+)\.(\d+)\.(\d+)\.(\d+)(?:/(\d+))?$', s)
m = re.match(r'(\d+)(?:\.(\d+)\.(\d+)\.(\d+))?(?:/(\d+))?$', s)
if not m:
raise Exception('%r is not a valid IP subnet format' % s)
(a,b,c,d,width) = m.groups()