From cc88cada8fe727fdf3a0d51ca4b1bf33432c8640 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 28 Sep 2015 20:34:50 +0000 Subject: [PATCH] (captiveportal, new) work in progress script base --- .../scripts/OPNsense/CaptivePortal/lib/ipfw.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/opnsense/scripts/OPNsense/CaptivePortal/lib/ipfw.py b/src/opnsense/scripts/OPNsense/CaptivePortal/lib/ipfw.py index 369e034ea..6aed4d10a 100644 --- a/src/opnsense/scripts/OPNsense/CaptivePortal/lib/ipfw.py +++ b/src/opnsense/scripts/OPNsense/CaptivePortal/lib/ipfw.py @@ -139,11 +139,12 @@ class IPFW(object): break # add accounting rule - DEVNULL = open(os.devnull, 'w') - subprocess.call(['/sbin/ipfw', 'add', 'count','ip','from', address, 'to', 'any'], - stdout=DEVNULL, stderr=DEVNULL) - subprocess.call(['/sbin/ipfw', 'add', 'count','ip','from', 'any', 'to', address], - stdout=DEVNULL, stderr=DEVNULL) + if newRuleid != -1: + DEVNULL = open(os.devnull, 'w') + subprocess.call(['/sbin/ipfw', 'add', str(newRuleid), 'count','ip','from', address, 'to', 'any'], + stdout=DEVNULL, stderr=DEVNULL) + subprocess.call(['/sbin/ipfw', 'add', str(newRuleid), 'count','ip','from', 'any', 'to', address], + stdout=DEVNULL, stderr=DEVNULL) def del_accounting(self, address): """ remove ip address from accounting rules @@ -153,5 +154,5 @@ class IPFW(object): acc_info = self.list_accounting_info() if address in acc_info: DEVNULL = open(os.devnull, 'w') - subprocess.call(['/sbin/ipfw', 'delete', acc_info[address]['rule']], + subprocess.call(['/sbin/ipfw', 'delete', str(acc_info[address]['rule'])], stdout=DEVNULL, stderr=DEVNULL)