summaryrefslogtreecommitdiff
path: root/src/leap/mx/alias_resolver.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2015-04-15 12:48:34 -0300
committerdrebs <drebs@leap.se>2015-04-16 11:53:13 -0300
commit527d7d4a67f859a3315812b100b2c58fd0eeded6 (patch)
treeb51959b18ec0053f9ed448cec9bd8c1bc98eb607 /src/leap/mx/alias_resolver.py
parent14ef3dcce18240b756415fefa2a56936f96a12e9 (diff)
[bug] return uuid as result of alias resolver
This fixes a bug introduced on b0ef529cc882a96903597fb5279919969fa286c3, when the alias resolver was modified to return the user's address instead of the uuid. In order to fix this, I had to revert one of the changes made by the commit above, which is to don't make use of reduced view for the uuid query. The pgp public key query remains reduced, as implemented in the commit above. We also refactor the code a bit to allow for log messages specific to each of tcp map's sublasses. Related: #6858.
Diffstat (limited to 'src/leap/mx/alias_resolver.py')
-rw-r--r--src/leap/mx/alias_resolver.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/leap/mx/alias_resolver.py b/src/leap/mx/alias_resolver.py
index dd631c8..752eac4 100644
--- a/src/leap/mx/alias_resolver.py
+++ b/src/leap/mx/alias_resolver.py
@@ -40,22 +40,26 @@ class LEAPPostfixTCPMapAliasServer(postfix.PostfixTCPMapServer):
A postfix tcp map alias resolver server.
"""
- def _cbGot(self, address):
+ def _cbGot(self, user_data):
"""
Return a code and message depending on the result of the factory's
get().
- :param address: The address returned by the factory.
- :type address: str
+ :param user_data: The user's uuid and pgp public key.
+ :type user_data: list
"""
- if address is None:
+ uuid, _ = user_data
+ if uuid is None:
self.sendCode(
TCP_MAP_CODE_PERMANENT_FAILURE,
postfix.quote("NOT FOUND SRY"))
else:
+ # properly encode uuid, otherwise twisted complains when replying
+ if isinstance(uuid, unicode):
+ uuid = uuid.encode("utf8")
self.sendCode(
TCP_MAP_CODE_SUCCESS,
- postfix.quote(address))
+ postfix.quote(uuid))
class AliasResolverFactory(LEAPPostfixTCPMapServerFactory):
@@ -64,3 +68,7 @@ class AliasResolverFactory(LEAPPostfixTCPMapServerFactory):
"""
protocol = LEAPPostfixTCPMapAliasServer
+
+ @property
+ def _query_message(self):
+ return "Resolving alias for"