コード例 #1
0
ファイル: service.py プロジェクト: rozanmartin/bitmask-dev
    def __init__(self, cfg, basepath=None):
        """
        Initialize VPN service. This launches both the firewall and the vpn.
        """
        super(VPNService, self).__init__()

        self._tunnel = None
        self._firewall = FirewallManager([])
        self._domain = ''
        self._cfg = cfg

        if basepath is None:
            self._basepath = get_path_prefix()
        else:
            self._basepath = basepath

        try:
            _cco = self._cfg.get('countries', "")
            self._cco = json.loads(_cco)
        except ValueError:
            self._cco = []
        try:
            _loc = self._cfg.get('locations', "")
            self._loc = json.loads(_loc)
        except ValueError:
            self._loc = []

        if helpers.check() and self._firewall.is_up():
            self._firewall.stop()
コード例 #2
0
 def do_check(self, domain=None):
     """Check whether the VPN Service is properly configured,
     and can be started"""
     ret = {'installed': helpers.check()}
     if domain:
         ret['vpn_ready'] = is_service_ready(domain)
         ret['cert_expires'] = self._cert_expires(domain)
     return ret
コード例 #3
0
ファイル: service.py プロジェクト: rozanmartin/bitmask-dev
 def do_check(self, domain=None):
     """Check whether the VPN Service is properly configured,
     and can be started"""
     ret = {'installed': helpers.check()}
     if domain:
         ret['vpn_ready'] = is_service_ready(domain)
         expiry = cert_expires(domain).strftime('%Y-%m-%dT%H:%M:%SZ')
         ret['cert_expires'] = expiry
     return ret
コード例 #4
0
ファイル: service.py プロジェクト: rrosajp/bitmask-dev
 def do_check(self, domain=None, timeout=1):
     """Check whether the VPN Service is properly configured,
     and can be started. This returns info about the helpers being
     installed, a polkit agent being present, and optionally a valid
     certificate present for a domain."""
     hashelpers = helpers.check()
     privcheck = helpers.privcheck(timeout=1)
     ret = {'installed': hashelpers, 'privcheck': privcheck}
     if not privcheck:
         if IS_LINUX:
             ret['error'] = 'nopolkit'
     if domain:
         ret['vpn_ready'] = is_service_ready(domain)
         expiry = cert_expires(domain)
         if expiry:
             expiry_ts = expiry.strftime('%Y-%m-%dT%H:%M:%SZ')
             ret['cert_expires'] = expiry_ts
     self.log.debug('VPN check: %s' % str(ret))
     return ret
コード例 #5
0
ファイル: service.py プロジェクト: rrosajp/bitmask-dev
    def __init__(self, cfg, basepath=None):
        """
        Initialize VPN service. This launches both the firewall and the vpn.
        """
        super(VPNService, self).__init__()

        self._tunnel = None
        self._firewall = FirewallManager([])
        self._domain = ''
        self._cfg = cfg

        if basepath is None:
            self._basepath = get_path_prefix()
        else:
            self._basepath = basepath

        try:
            _cco = self._cfg.get('countries', "")
            self._cco = json.loads(_cco)
        except ValueError:
            self._cco = []
        try:
            _loc = self._cfg.get('locations', "")
            self._loc = json.loads(_loc)
        except ValueError:
            self._loc = []

        _autostart = self._cfg.get('autostart', False, boolean=True)
        self._autostart = _autostart

        _anonymous = self._cfg.get('anonymous', True, boolean=True)
        self._anonymous_enabled = _anonymous

        if helpers.check() and self._firewall.is_up():
            self._firewall.stop()

        self.watchdog = LoopingCall(self.push_status)