summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2013-09-03 11:12:18 +0200
committerKali Kaneko <kali@leap.se>2013-09-03 11:12:18 +0200
commitb6123d0f98a60914e5d6a0a6d4f80f72b935a697 (patch)
tree7b77eb7f82dc6ec2ebfd1114cb7896740a344d8a
parent33da8094f99a87fb58eb0950bd9acbef04395f71 (diff)
Return SMTP factory so the client can stop it.
-rw-r--r--mail/changes/feature_return-smtp-factory1
-rw-r--r--mail/src/leap/mail/smtp/__init__.py35
2 files changed, 20 insertions, 16 deletions
diff --git a/mail/changes/feature_return-smtp-factory b/mail/changes/feature_return-smtp-factory
new file mode 100644
index 0000000..d46cac3
--- /dev/null
+++ b/mail/changes/feature_return-smtp-factory
@@ -0,0 +1 @@
+ o SMTP service invocation returns factory instance.
diff --git a/mail/src/leap/mail/smtp/__init__.py b/mail/src/leap/mail/smtp/__init__.py
index d5d61bf..cc9cc26 100644
--- a/mail/src/leap/mail/smtp/__init__.py
+++ b/mail/src/leap/mail/smtp/__init__.py
@@ -37,22 +37,24 @@ def setup_smtp_relay(port, keymanager, smtp_host, smtp_port,
This function sets up the SMTP relay configuration and the Twisted
reactor.
- @param port: The port in which to run the server.
- @type port: int
- @param keymanager: A Key Manager from where to get recipients' public
- keys.
- @type keymanager: leap.common.keymanager.KeyManager
- @param smtp_host: The hostname of the remote SMTP server.
- @type smtp_host: str
- @param smtp_port: The port of the remote SMTP server.
- @type smtp_port: int
- @param smtp_cert: The client certificate for authentication.
- @type smtp_cert: str
- @param smtp_key: The client key for authentication.
- @type smtp_key: str
- @param encrypted_only: Whether the SMTP relay should send unencrypted mail
- or not.
- @type encrypted_only: bool
+ :param port: The port in which to run the server.
+ :type port: int
+ :param keymanager: A Key Manager from where to get recipients' public
+ keys.
+ :type keymanager: leap.common.keymanager.KeyManager
+ :param smtp_host: The hostname of the remote SMTP server.
+ :type smtp_host: str
+ :param smtp_port: The port of the remote SMTP server.
+ :type smtp_port: int
+ :param smtp_cert: The client certificate for authentication.
+ :type smtp_cert: str
+ :param smtp_key: The client key for authentication.
+ :type smtp_key: str
+ :param encrypted_only: Whether the SMTP relay should send unencrypted mail
+ or not.
+ :type encrypted_only: bool
+
+ :returns: SMTPFactory
"""
# The configuration for the SMTP relay is a dict with the following
# format:
@@ -77,6 +79,7 @@ def setup_smtp_relay(port, keymanager, smtp_host, smtp_port,
try:
reactor.listenTCP(port, factory)
signal(proto.SMTP_SERVICE_STARTED, str(smtp_port))
+ return factory
except CannotListenError:
logger.error("STMP Service failed to start: "
"cannot listen in port %s" % (