From 9c4bf6adf42f0f9553ae11f24ffeb6f7cf39f374 Mon Sep 17 00:00:00 2001 From: drebs Date: Tue, 27 Sep 2016 20:44:53 -0300 Subject: [refactor] turn mail services into twisted services --- src/leap/bitmask/mail/smtp/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/leap/bitmask/mail/smtp/__init__.py') diff --git a/src/leap/bitmask/mail/smtp/__init__.py b/src/leap/bitmask/mail/smtp/__init__.py index 4e0ac894..f8b8e65f 100644 --- a/src/leap/bitmask/mail/smtp/__init__.py +++ b/src/leap/bitmask/mail/smtp/__init__.py @@ -32,7 +32,7 @@ SMTP_PORT = 2013 def run_service(soledad_sessions, keymanager_sessions, sendmail_opts, - port=SMTP_PORT): + port=SMTP_PORT, factory=None): """ Main entry point to run the service from the client. @@ -46,8 +46,9 @@ def run_service(soledad_sessions, keymanager_sessions, sendmail_opts, the factory for the protocol. :rtype: tuple """ - factory = SMTPFactory(soledad_sessions, keymanager_sessions, - sendmail_opts) + if not factory: + factory = SMTPFactory(soledad_sessions, keymanager_sessions, + sendmail_opts) try: interface = "localhost" @@ -60,7 +61,7 @@ def run_service(soledad_sessions, keymanager_sessions, sendmail_opts, tport = reactor.listenTCP(port, factory, interface=interface) emit_async(catalog.SMTP_SERVICE_STARTED, str(port)) - return factory, tport + return tport, factory except CannotListenError: logger.error("SMTP Service failed to start: " "cannot listen in port %s" % port) -- cgit v1.2.3