summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/leap/mx/alias_resolver.py4
-rw-r--r--src/leap/mx/couchdbhelper.py6
-rwxr-xr-xstart_mx.py16
3 files changed, 16 insertions, 10 deletions
diff --git a/src/leap/mx/alias_resolver.py b/src/leap/mx/alias_resolver.py
index eb08c06..8155ff9 100644
--- a/src/leap/mx/alias_resolver.py
+++ b/src/leap/mx/alias_resolver.py
@@ -45,13 +45,17 @@ class AliasResolverFactory(postfix.PostfixTCPMapDeferringDictServerFactory):
def _to_str(self, result):
if isinstance(result, unicode):
result = result.encode("utf8")
+ if result is None:
+ logger.debug("Result not found")
return result
def get(self, key):
orig_key = key
try:
+ logger.debug("Processing key: %s" % (key,))
key = key.split("@")[0]
key = key.split("+")[0]
+ logger.debug("Final key to query: %s" % (key,))
except Exception as e:
key = orig_key
logger.exception("%s" % (e,))
diff --git a/src/leap/mx/couchdbhelper.py b/src/leap/mx/couchdbhelper.py
index cbb087d..4e76be3 100644
--- a/src/leap/mx/couchdbhelper.py
+++ b/src/leap/mx/couchdbhelper.py
@@ -114,7 +114,8 @@ class ConnectedCouchDB(client.CouchDB):
d = self.openView(docId="User",
viewId="by_login_or_alias/",
key=alias,
- reduce=False)
+ reduce=False,
+ include_docs=True)
d.addCallbacks(partial(self._get_uuid, alias), log.err)
@@ -135,7 +136,7 @@ class ConnectedCouchDB(client.CouchDB):
for row in result["rows"]:
if row["key"] == alias:
uuid = row["id"]
- self._cache[uuid] = row["value"]
+ self._cache[uuid] = row["doc"]["public_key"]
return uuid
return None
@@ -161,6 +162,7 @@ if __name__ == "__main__":
@d.addCallback
def right(result):
print "Should be an actual uuid:", result
+ print "Public Key:"
print cdb.getPubKey(result)
d2 = cdb.queryByLoginOrAlias("asdjaoisdjoiqwjeoi")
diff --git a/start_mx.py b/start_mx.py
index d2905c5..c802852 100755
--- a/start_mx.py
+++ b/start_mx.py
@@ -22,7 +22,7 @@ import ConfigParser
import logging
try:
- from leap.mx import couchdb
+ from leap.mx import couchdbhelper
from leap.mx.alias_resolver import AliasResolverFactory
except ImportError, ie:
print "%s \nExiting... \n" % ie.message
@@ -35,8 +35,6 @@ except ImportError, ie:
print "This software requires Twisted>=12.0.2, please see the README for"
print "help on using virtualenv and pip to obtain requirements."
-logger = logging.getLogger(__name__)
-
if __name__ == "__main__":
epilog = "Copyright 2012 The LEAP Encryption Access Project"
@@ -54,6 +52,8 @@ if __name__ == "__main__":
opts, _ = parser.parse_known_args()
+ logger = logging.getLogger(name='leap')
+
debug = opts.debug
config_file = opts.config
@@ -92,11 +92,11 @@ if __name__ == "__main__":
server = config.get("couchdb", "server")
port = config.get("couchdb", "port")
- cdb = couchdb.ConnectedCouchDB(server,
- port=port,
- dbName="users",
- username=users_user,
- password=users_password)
+ cdb = couchdbhelper.ConnectedCouchDB(server,
+ port=port,
+ dbName="users",
+ username=users_user,
+ password=users_password)
# TODO: use the couchdb for mail