From fc257dda59f5ce638e59f6f8dd3f5bc8cc93b899 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= <chiiph@leap.se>
Date: Thu, 3 Oct 2013 20:38:26 -0300
Subject: Return smtp's Port to be able to stop listening to it

---
 mail/src/leap/mail/smtp/__init__.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'mail/src/leap')

diff --git a/mail/src/leap/mail/smtp/__init__.py b/mail/src/leap/mail/smtp/__init__.py
index 2a4abc5..4e5d2a0 100644
--- a/mail/src/leap/mail/smtp/__init__.py
+++ b/mail/src/leap/mail/smtp/__init__.py
@@ -54,7 +54,7 @@ def setup_smtp_relay(port, keymanager, smtp_host, smtp_port,
                            or not.
     :type encrypted_only: bool
 
-    :returns: SMTPFactory
+    :returns: tuple of SMTPFactory, twisted.internet.tcp.Port
     """
     # The configuration for the SMTP relay is a dict with the following
     # format:
@@ -77,10 +77,10 @@ def setup_smtp_relay(port, keymanager, smtp_host, smtp_port,
     # configure the use of this service with twistd
     factory = SMTPFactory(keymanager, config)
     try:
-        reactor.listenTCP(port, factory,
-                          interface="localhost")
+        tport = reactor.listenTCP(port, factory,
+                                  interface="localhost")
         signal(proto.SMTP_SERVICE_STARTED, str(smtp_port))
-        return factory
+        return factory, tport
     except CannotListenError:
         logger.error("STMP Service failed to start: "
                      "cannot listen in port %s" % (
-- 
cgit v1.2.3