summaryrefslogtreecommitdiff
path: root/src/leap/mx/tcp_map.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/mx/tcp_map.py')
-rw-r--r--src/leap/mx/tcp_map.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/leap/mx/tcp_map.py b/src/leap/mx/tcp_map.py
index d8cd835..108c2aa 100644
--- a/src/leap/mx/tcp_map.py
+++ b/src/leap/mx/tcp_map.py
@@ -17,8 +17,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from twisted.python import log
+from abc import ABCMeta
+from abc import abstractproperty
+
from twisted.internet.protocol import ServerFactory
+from twisted.python import log
# For info on codes, see: http://www.postfix.org/tcp_table.5.html
@@ -27,11 +30,14 @@ TCP_MAP_CODE_TEMPORARY_FAILURE = 400
TCP_MAP_CODE_PERMANENT_FAILURE = 500
-class LEAPPostfixTCPMapServerFactory(ServerFactory):
+class LEAPPostfixTCPMapServerFactory(ServerFactory, object):
"""
A factory for postfix tcp map servers.
"""
+ __metaclass__ = ABCMeta
+
+
def __init__(self, couchdb):
"""
Initialize the factory.
@@ -41,14 +47,22 @@ class LEAPPostfixTCPMapServerFactory(ServerFactory):
"""
self._cdb = couchdb
- def get(self, key):
+ @abstractproperty
+ def _query_message(self):
+ pass
+
+ def get(self, lookup_key):
"""
- Look up if address exists.
+ Look up user based on lookup_key.
+
+ :param lookup_key: The lookup key.
+ :type lookup_key: str
- :param key: The lookup key.
- :type key: str
+ :return: A deferred that will be fired with the user's address, uuid
+ and pgp key.
+ :rtype: Deferred
"""
- log.msg("Query key: %s" % (key,))
- d = self._cdb.queryByAddress(key)
+ log.msg("%s %s" % (self._query_message, lookup_key,))
+ d = self._cdb.getUuidAndPubkey(lookup_key)
d.addErrback(log.err)
return d