summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-10-03 20:38:26 -0300
committerTomás Touceda <chiiph@leap.se>2013-10-03 20:39:45 -0300
commitfc257dda59f5ce638e59f6f8dd3f5bc8cc93b899 (patch)
treef8e9c06845bcc8cd5bd75e62c330939a49d6d5e8
parente380c685088183f5c6aff134a4c9b7591f923067 (diff)
Return smtp's Port to be able to stop listening to it
-rw-r--r--mail/changes/return_smtp_port2
-rw-r--r--mail/src/leap/mail/smtp/__init__.py8
2 files changed, 6 insertions, 4 deletions
diff --git a/mail/changes/return_smtp_port b/mail/changes/return_smtp_port
new file mode 100644
index 00000000..1cf58ef7
--- /dev/null
+++ b/mail/changes/return_smtp_port
@@ -0,0 +1,2 @@
+ o Return Twisted's smtp Port object to be able to stop listening to
+ it whenever we want. Related to #3873. \ No newline at end of file
diff --git a/mail/src/leap/mail/smtp/__init__.py b/mail/src/leap/mail/smtp/__init__.py
index 2a4abc57..4e5d2a00 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" % (