From ca0e1c4518749e27bccad817d22ab87afbf8acf7 Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Tue, 31 Jan 2017 13:31:13 +0100 Subject: [feature] initial port of legacy vpn code non functional at the moment, but started doing some cleanup --- src/leap/bitmask/vpn/eip.py | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/leap/bitmask/vpn/eip.py (limited to 'src/leap/bitmask/vpn/eip.py') diff --git a/src/leap/bitmask/vpn/eip.py b/src/leap/bitmask/vpn/eip.py new file mode 100644 index 00000000..cfd8b592 --- /dev/null +++ b/src/leap/bitmask/vpn/eip.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# cli.py +# Copyright (C) 2015 LEAP +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 . + +from colorama import Fore + +from leap.bitmask.vpn import VPNManager +from leap.bitmask.vpn.fw.firewall import FirewallManager +from leap.bitmask.vpn.statusqueue import StatusQueue +from leap.bitmask.vpn.zmq_pub import ZMQPublisher + + +class EIPManager(object): + + def __init__(self, remotes, cert, key, ca, flags): + + self._firewall = FirewallManager(remotes) + self._status_queue = StatusQueue() + self._pub = ZMQPublisher(self._status_queue) + self._vpn = VPNManager(remotes, cert, key, ca, flags, + self._status_queue) + + def start(self): + """ + Start EIP service (firewall and vpn) + + This may raise exceptions, see errors.py + """ + # self._pub.start() + print(Fore.BLUE + "Firewall: starting..." + Fore.RESET) + fw_ok = self._firewall.start() + if not fw_ok: + return False + + print(Fore.GREEN + "Firewall: started" + Fore.RESET) + + vpn_ok = self._vpn.start() + if not vpn_ok: + print (Fore.RED + "VPN: Error starting." + Fore.RESET) + self._firewall.stop() + print(Fore.GREEN + "Firewall: stopped." + Fore.RESET) + return False + + print(Fore.GREEN + "VPN: started" + Fore.RESET) + + def stop(self): + """ + Stop EIP service + """ + # self._pub.stop() + print(Fore.BLUE + "Firewall: stopping..." + Fore.RESET) + fw_ok = self._firewall.stop() + + if not fw_ok: + print (Fore.RED + "Firewall: Error stopping." + Fore.RESET) + return False + + print(Fore.GREEN + "Firewall: stopped." + Fore.RESET) + print(Fore.BLUE + "VPN: stopping..." + Fore.RESET) + + vpn_ok = self._vpn.stop() + if not vpn_ok: + print (Fore.RED + "VPN: Error stopping." + Fore.RESET) + return False + + print(Fore.GREEN + "VPN: stopped." + Fore.RESET) + return True + + def get_state(self): + pass + + def get_status(self): + pass -- cgit v1.2.3