From 701fe5ebc70fb49bb32e81e6d6605f27ad09925b Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Sat, 4 Feb 2017 17:01:25 +0100 Subject: [feature] parse status - simple status parsing - add separate firewall status - set status for abnormal termination --- src/leap/bitmask/vpn/fw/firewall.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/leap/bitmask/vpn/fw') diff --git a/src/leap/bitmask/vpn/fw/firewall.py b/src/leap/bitmask/vpn/fw/firewall.py index 4335b8e9..5eace20a 100644 --- a/src/leap/bitmask/vpn/fw/firewall.py +++ b/src/leap/bitmask/vpn/fw/firewall.py @@ -13,7 +13,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# alng with this program. If not, see . """ Firewall Manager @@ -44,6 +44,7 @@ class FirewallManager(object): :param remotes: the gateway(s) that we will allow :type remotes: list """ + self.status = 'OFF' self._remotes = remotes def start(self, restart=False): @@ -65,7 +66,13 @@ class FirewallManager(object): # FIXME -- use a processprotocol exitCode = subprocess.call(cmd + gateways) - return True if exitCode is 0 else False + + if exitCode == 0: + self.status = 'ON' + return True + else: + self.status = 'OFF' + return False # def tear_down_firewall(self): def stop(self): @@ -78,9 +85,13 @@ class FirewallManager(object): exitCode = subprocess.call(["pkexec", self.BITMASK_ROOT, "firewall", "stop"]) - return True if exitCode is 0 else False + if exitCode == 0: + self.status = 'OFF' + return True + else: + self.status = 'ON' + return False - # def is_fw_down(self): def is_up(self): """ Return whether the firewall is up or not. -- cgit v1.2.3