summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/leap/bitmask/cli/mail.py21
-rw-r--r--src/leap/bitmask/core/configurable.py1
-rw-r--r--src/leap/bitmask/core/dispatcher.py11
-rw-r--r--src/leap/bitmask/core/mail_services.py11
-rw-r--r--src/leap/bitmask/core/service.py21
-rw-r--r--ui/app/lib/bitmask.js13
6 files changed, 65 insertions, 13 deletions
diff --git a/src/leap/bitmask/cli/mail.py b/src/leap/bitmask/cli/mail.py
index 1624606a..21b93c24 100644
--- a/src/leap/bitmask/cli/mail.py
+++ b/src/leap/bitmask/cli/mail.py
@@ -20,8 +20,6 @@ Bitmask Command Line interface: mail
import argparse
import sys
-from colorama import Fore
-
from leap.bitmask.cli import command
@@ -58,3 +56,22 @@ SUBCOMMANDS:
self.data += ['status', uid]
return self._send(command.print_status)
+
+ def mixnet_status(self, raw_args):
+ parser = argparse.ArgumentParser(
+ description='Bitmask mixnet status',
+ prog='%s %s %s' % tuple(sys.argv[:3]))
+ parser.add_argument('-u', '--userid', default='',
+ help='uid to check the status of')
+ parser.add_argument('address', nargs=1,
+ help='the recipient address')
+ subargs = parser.parse_args(raw_args)
+
+ userid = None
+ if subargs.userid:
+ userid = subargs.userid
+ else:
+ userid = self.cfg.get('bonafide', 'active', default=None)
+ self.data += ['mixnet_status', userid, subargs.address[0]]
+
+ return self._send(command.default_dict_printer)
diff --git a/src/leap/bitmask/core/configurable.py b/src/leap/bitmask/core/configurable.py
index 726c541a..262f0300 100644
--- a/src/leap/bitmask/core/configurable.py
+++ b/src/leap/bitmask/core/configurable.py
@@ -51,6 +51,7 @@ zmq = True
web = True
onion = False
websockets = False
+mixnet = False
"""
__all__ = ["ConfigurableService", DEFAULT_BASEDIR, MissingConfigEntry]
diff --git a/src/leap/bitmask/core/dispatcher.py b/src/leap/bitmask/core/dispatcher.py
index 7a2d48a2..519ec9df 100644
--- a/src/leap/bitmask/core/dispatcher.py
+++ b/src/leap/bitmask/core/dispatcher.py
@@ -267,6 +267,17 @@ class MailCmd(SubCommand):
d = mail.get_token()
return d
+ @register_method('dict')
+ def do_MIXNET_STATUS(self, mail, *parts, **kw):
+ try:
+ userid = parts[2]
+ address = parts[3]
+ except IndexError:
+ raise DispatchError(
+ 'wrong number of arguments: expected 2')
+ d = mail.do_mixnet_status(userid, address)
+ return d
+
class WebUICmd(SubCommand):
diff --git a/src/leap/bitmask/core/mail_services.py b/src/leap/bitmask/core/mail_services.py
index 20d6a342..be84b3cf 100644
--- a/src/leap/bitmask/core/mail_services.py
+++ b/src/leap/bitmask/core/mail_services.py
@@ -469,13 +469,14 @@ class StandardMailService(service.MultiService, HookableService):
# TODO factor out Mail Service to inside mail package.
- def __init__(self, basedir):
+ def __init__(self, basedir, mixnet_enabled=False):
self._basedir = basedir
self._soledad_sessions = {}
self._keymanager_sessions = {}
self._sendmail_opts = {}
self._service_tokens = {}
self._active_user = None
+ self._mixnet_enabled = mixnet_enabled
super(StandardMailService, self).__init__()
self.initializeChildrenServices()
@@ -603,6 +604,14 @@ class StandardMailService(service.MultiService, HookableService):
}
defer.returnValue(merge_status(childrenStatus))
+ def do_mixnet_status(self, userid, address):
+ # XXX: for now there is no support in the provider
+ # we'll mock it if it's enabled
+ status = 'disabled'
+ if self._mixnet_enabled:
+ status = 'ok'
+ return {'status': status}
+
def get_token(self):
active_user = self._active_user
if not active_user:
diff --git a/src/leap/bitmask/core/service.py b/src/leap/bitmask/core/service.py
index 5b4f5f79..e823d829 100644
--- a/src/leap/bitmask/core/service.py
+++ b/src/leap/bitmask/core/service.py
@@ -83,9 +83,6 @@ class BitmaskBackend(configurable.ConfigurableService):
# top of the global app token, this should be removed.
self.tokens = {}
- def enabled(service):
- return self.get_config('services', service, False, boolean=True)
-
def with_manhole():
user = self.get_config('manhole', 'user', '')
passwd = self.get_config('manhole', 'passwd', '')
@@ -101,26 +98,29 @@ class BitmaskBackend(configurable.ConfigurableService):
on_start(self.init_bonafide)
on_start(self.init_sessions)
- if enabled('mail'):
+ if self._enabled('mail'):
on_start(self._init_mail_services)
- if enabled('vpn'):
+ if self._enabled('vpn'):
on_start(self._init_vpn)
- if enabled('zmq'):
+ if self._enabled('zmq'):
on_start(self._init_zmq)
- if enabled('web'):
- onion = enabled('onion')
+ if self._enabled('web'):
+ onion = self._enabled('onion')
on_start(self._init_web, onion=onion)
- if enabled('websockets'):
+ if self._enabled('websockets'):
on_start(self._init_websockets)
manholecfg = with_manhole()
if manholecfg:
on_start(self._init_manhole, manholecfg)
+ def _enabled(self, service):
+ return self.get_config('services', service, False, boolean=True)
+
def _touch_token_file(self):
path = os.path.join(self.basedir, 'authtoken')
with open(path, 'w') as f:
@@ -203,7 +203,8 @@ class BitmaskBackend(configurable.ConfigurableService):
def _init_mail(self):
service = mail_services.StandardMailService
- self._maybe_init_service('mail', service, self.basedir)
+ self._maybe_init_service('mail', service, self.basedir,
+ self._enabled('mixnet'))
def _init_vpn(self):
if HAS_VPN:
diff --git a/ui/app/lib/bitmask.js b/ui/app/lib/bitmask.js
index 72c027cb..bef54013 100644
--- a/ui/app/lib/bitmask.js
+++ b/ui/app/lib/bitmask.js
@@ -320,6 +320,19 @@ var bitmask = function(){
*/
get_token: function() {
return call(['mail', 'get_token']);
+ },
+
+ /**
+ * Get status on the mixnet for an address.
+ *
+ * @param {string} uid The uid to get status about
+ * @param {string} address The recipient address to be mixed
+ *
+ * @return {Promise<{'status': string}>} Where the status string can be 'ok',
+ * 'unsuported' or 'disabled'
+ */
+ mixnet_status: function(uid, address) {
+ return call(['mail', 'mixnet_status', uid, address]);
}
},