From 513a1c153c7d4a3a0b787a1cb83816c905d191d4 Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Thu, 5 Apr 2018 18:54:47 +0200 Subject: [feat] add fw_reload to bitmaskctl Some systems remove firewall rules, is usefull to be able to script the reload of those rules in hooks or other custom systems. - Resolves: #9289 --- src/leap/bitmask/vpn/service.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/leap/bitmask/vpn') diff --git a/src/leap/bitmask/vpn/service.py b/src/leap/bitmask/vpn/service.py index 4ce573ba..da33e82b 100644 --- a/src/leap/bitmask/vpn/service.py +++ b/src/leap/bitmask/vpn/service.py @@ -182,6 +182,21 @@ class VPNService(HookableService): self.watchdog.stop() return {'result': 'vpn stopped'} + def fw_reload(self): + if not self._tunnel: + return {'result': 'VPN was not running'} + + if self._firewall.is_up(): + fw_ok = self._firewall.stop() + if not fw_ok: + self.log.error('Firewall: error stopping') + + fw_ok = self._firewall.start() + if not fw_ok: + raise Exception('Could not start firewall') + + return {'result': 'fw reloaded'} + def push_status(self): try: statusdict = self.do_status() -- cgit v1.2.3