Example #1
0
class EIPManager(object):
    def __init__(self, remotes, cert, key, ca, flags):
        """
        """
        self._firewall = FirewallManager(remotes)
        self._vpn = VPNManager(remotes, cert, key, ca, flags)

    def start(self):
        """TODO: Docstring for start.
        :returns: TODO

        """
        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):
        """TODO: Docstring for stop.

        :returns: TODO
        """
        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
Example #2
0
class EIPManager(object):
    def __init__(self, remotes, cert, key, ca, flags):
        """
        """
        self._firewall = FirewallManager(remotes)
        self._vpn = VPNManager(remotes, cert, key, ca, flags)

    def start(self):
        """TODO: Docstring for start.
        :returns: TODO

        """
        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):
        """TODO: Docstring for stop.

        :returns: TODO
        """
        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
Example #3
0
File: eip.py Project: azul/leap_vpn
 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)
Example #4
0
def test_vpn():
    remotes = (  # XXX HACK picked manually from eip-service.json
        ("198.252.153.84", "1194"),
        ("46.165.242.169", "1194"),
    )

    prefix = os.path.join(get_path_prefix(),
                          "leap/providers/demo.bitmask.net/keys")
    cert_path = key_path = prefix + "/client/openvpn.pem"
    ca_path = prefix + "/ca/cacert.pem"

    extra_flags = {
        "auth": "SHA1",
        "cipher": "AES-128-CBC",
        "keepalive": "10 30",
        "tls-cipher": "DHE-RSA-AES128-SHA",
        "tun-ipv6": "true",
    }

    vpn = VPNManager(remotes, cert_path, key_path, ca_path, extra_flags)

    print("VPN: starting...")
    vpn_ok = vpn.start()
    if vpn_ok:
        print("VPN: started")
    else:
        print ("VPN: Error starting.")
        return

    return
    wait(1)
    print "VPN: is up? -> " + str(vpn.is_up())
    wait(3)
    print("VPN: stopping...")
    vpn_ok = vpn.stop()
    print("VPN: stopped.")
    wait(1)
    print "VPN: is up? -> " + str(vpn.is_up())
Example #5
0
def test_vpn():
    remotes = (  # XXX HACK picked manually from eip-service.json
        ("198.252.153.84", "1194"),
        ("46.165.242.169", "1194"),
    )

    prefix = os.path.join(get_path_prefix(),
                          "leap/providers/demo.bitmask.net/keys")
    cert_path = key_path = prefix + "/client/openvpn.pem"
    ca_path = prefix + "/ca/cacert.pem"

    extra_flags = {
        "auth": "SHA1",
        "cipher": "AES-128-CBC",
        "keepalive": "10 30",
        "tls-cipher": "DHE-RSA-AES128-SHA",
        "tun-ipv6": "true",
    }

    vpn = VPNManager(remotes, cert_path, key_path, ca_path, extra_flags)

    print("VPN: starting...")
    vpn_ok = vpn.start()
    if vpn_ok:
        print("VPN: started")
    else:
        print("VPN: Error starting.")
        return

    return
    wait(1)
    print "VPN: is up? -> " + str(vpn.is_up())
    wait(3)
    print("VPN: stopping...")
    vpn_ok = vpn.stop()
    print("VPN: stopped.")
    wait(1)
    print "VPN: is up? -> " + str(vpn.is_up())
Example #6
0
 def __init__(self, remotes, cert, key, ca, flags):
     """
     """
     self._firewall = FirewallManager(remotes)
     self._vpn = VPNManager(remotes, cert, key, ca, flags)
Example #7
0
 def __init__(self, remotes, cert, key, ca, flags):
     """
     """
     self._firewall = FirewallManager(remotes)
     self._vpn = VPNManager(remotes, cert, key, ca, flags)
Example #8
0
File: eip.py Project: azul/leap_vpn
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