summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-11-07 17:09:56 -0200
committerdrebs <drebs@leap.se>2013-11-11 12:25:16 -0200
commit8d1018c2e6636349a12aeb1f9de595dabfed8096 (patch)
tree34e43795074dfe1c9b1965ffafd2e164709fc0bf
parent9b3372167326f6464cb7e725a8a30d3629afb286 (diff)
Change SMTP "relay" to "gateway".
-rw-r--r--mail/changes/bug_4416-change-smtp-relay-to-gateway1
-rw-r--r--mail/src/leap/mail/smtp/README.rst38
-rw-r--r--mail/src/leap/mail/smtp/__init__.py14
-rw-r--r--mail/src/leap/mail/smtp/gateway.py (renamed from mail/src/leap/mail/smtp/smtprelay.py)22
-rw-r--r--mail/src/leap/mail/smtp/tests/__init__.py2
-rw-r--r--mail/src/leap/mail/smtp/tests/test_gateway.py (renamed from mail/src/leap/mail/smtp/tests/test_smtprelay.py)20
6 files changed, 39 insertions, 58 deletions
diff --git a/mail/changes/bug_4416-change-smtp-relay-to-gateway b/mail/changes/bug_4416-change-smtp-relay-to-gateway
new file mode 100644
index 00000000..08bead7e
--- /dev/null
+++ b/mail/changes/bug_4416-change-smtp-relay-to-gateway
@@ -0,0 +1 @@
+ o Change SMTP service name from "relay" to "gateway". Closes #4416.
diff --git a/mail/src/leap/mail/smtp/README.rst b/mail/src/leap/mail/smtp/README.rst
index 2b2a1180..f6254419 100644
--- a/mail/src/leap/mail/smtp/README.rst
+++ b/mail/src/leap/mail/smtp/README.rst
@@ -1,43 +1,23 @@
-Leap SMTP Relay
-===============
+Leap SMTP Gateway
+=================
Outgoing mail workflow:
* LEAP client runs a thin SMTP proxy on the user's device, bound to
localhost.
- * User's MUA is configured outgoing SMTP to localhost
- * When SMTP proxy receives an email from MUA
+ * User's MUA is configured outgoing SMTP to localhost.
+ * When SMTP proxy receives an email from MUA:
* SMTP proxy queries Key Manager for the user's private key and public
- keys of all recipients
+ keys of all recipients.
* Message is signed by sender and encrypted to recipients.
* If recipient's key is missing, email goes out in cleartext (unless
- user has configured option to send only encrypted email)
- * Finally, message is relayed to provider's SMTP relay
-
-
-Dependencies
-------------
-
-Leap SMTP Relay depends on the following python libraries:
-
- * Twisted 12.3.0 [1]
- * zope.interface 4.0.3 [2]
-
-[1] http://pypi.python.org/pypi/Twisted/12.3.0
-[2] http://pypi.python.org/pypi/zope.interface/4.0.3
-
-
-How to run
-----------
-
-To launch the SMTP relay, run the following command:
-
- twistd -y smtprelay.tac
+ user has configured option to send only encrypted email).
+ * Finally, message is gatewayed to provider's SMTP server.
Running tests
-------------
-Tests are run using Twisted's Trial API, like this:
+Tests are run using Twisted's Trial API, like this::
- trial leap.email.smtp.tests
+ python setup.py test -s leap.mail.gateway.tests
diff --git a/mail/src/leap/mail/smtp/__init__.py b/mail/src/leap/mail/smtp/__init__.py
index 753ef348..d3eb9e85 100644
--- a/mail/src/leap/mail/smtp/__init__.py
+++ b/mail/src/leap/mail/smtp/__init__.py
@@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
-SMTP relay helper function.
+SMTP gateway helper function.
"""
import logging
@@ -26,15 +26,15 @@ from twisted.internet.error import CannotListenError
logger = logging.getLogger(__name__)
from leap.common.events import proto, signal
-from leap.mail.smtp.smtprelay import SMTPFactory
+from leap.mail.smtp.gateway import SMTPFactory
-def setup_smtp_relay(port, userid, keymanager, smtp_host, smtp_port,
+def setup_smtp_gateway(port, userid, keymanager, smtp_host, smtp_port,
smtp_cert, smtp_key, encrypted_only):
"""
- Setup SMTP relay to run with Twisted.
+ Setup SMTP gateway to run with Twisted.
- This function sets up the SMTP relay configuration and the Twisted
+ This function sets up the SMTP gateway configuration and the Twisted
reactor.
:param port: The port in which to run the server.
@@ -52,7 +52,7 @@ def setup_smtp_relay(port, userid, keymanager, smtp_host, smtp_port,
: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
+ :param encrypted_only: Whether the SMTP gateway should send unencrypted mail
or not.
:type encrypted_only: bool
@@ -70,5 +70,5 @@ def setup_smtp_relay(port, userid, keymanager, smtp_host, smtp_port,
"cannot listen in port %s" % port)
signal(proto.SMTP_SERVICE_FAILED_TO_START, str(port))
except Exception as exc:
- logger.error("Unhandled error while launching smtp relay service")
+ logger.error("Unhandled error while launching smtp gateway service")
logger.exception(exc)
diff --git a/mail/src/leap/mail/smtp/smtprelay.py b/mail/src/leap/mail/smtp/gateway.py
index 474fc3b7..06405b4e 100644
--- a/mail/src/leap/mail/smtp/smtprelay.py
+++ b/mail/src/leap/mail/smtp/gateway.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# smtprelay.py
+# gateway.py
# Copyright (C) 2013 LEAP
#
# This program is free software: you can redistribute it and/or modify
@@ -16,9 +16,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
-LEAP SMTP encrypted relay.
+LEAP SMTP encrypted gateway.
-The following classes comprise the SMTP relay service:
+The following classes comprise the SMTP gateway service:
* SMTPFactory - A twisted.internet.protocol.ServerFactory that provides
the SMTPDelivery protocol.
@@ -98,7 +98,7 @@ def validate_address(address):
class SMTPFactory(ServerFactory):
"""
- Factory for an SMTP server with encrypted relaying capabilities.
+ Factory for an SMTP server with encrypted gatewaying capabilities.
"""
def __init__(self, userid, keymanager, host, port, cert, key,
@@ -118,8 +118,8 @@ class SMTPFactory(ServerFactory):
:type cert: str
:param key: The client key for authentication.
:type key: str
- :param encrypted_only: Whether the SMTP relay should send unencrypted mail
- or not.
+ :param encrypted_only: Whether the SMTP gateway should send unencrypted
+ mail or not.
:type encrypted_only: bool
"""
# assert params
@@ -128,9 +128,9 @@ class SMTPFactory(ServerFactory):
leap_assert(host != '')
leap_assert_type(port, int)
leap_assert(port is not 0)
- leap_assert_type(cert, str)
+ leap_assert_type(cert, unicode)
leap_assert(cert != '')
- leap_assert_type(key, str)
+ leap_assert_type(key, unicode)
leap_assert(key != '')
leap_assert_type(encrypted_only, bool)
# and store them
@@ -187,8 +187,8 @@ class SMTPDelivery(object):
:type cert: str
:param key: The client key for authentication.
:type key: str
- :param encrypted_only: Whether the SMTP relay should send unencrypted mail
- or not.
+ :param encrypted_only: Whether the SMTP gateway should send unencrypted
+ mail or not.
:type encrypted_only: bool
"""
self._userid = userid
@@ -545,7 +545,7 @@ class EncryptedMessage(object):
the recipient's public key is not available, then the recipient
address would have been rejected in SMTPDelivery.validateTo().
- The following table summarizes the overall behaviour of the relay:
+ The following table summarizes the overall behaviour of the gateway:
+---------------------------------------------------+----------------+
| content-type | rcpt pubkey | enforce encr. | action |
diff --git a/mail/src/leap/mail/smtp/tests/__init__.py b/mail/src/leap/mail/smtp/tests/__init__.py
index ee6de9bb..62b015f0 100644
--- a/mail/src/leap/mail/smtp/tests/__init__.py
+++ b/mail/src/leap/mail/smtp/tests/__init__.py
@@ -17,7 +17,7 @@
"""
-Base classes and keys for SMTP relay tests.
+Base classes and keys for SMTP gateway tests.
"""
import os
diff --git a/mail/src/leap/mail/smtp/tests/test_smtprelay.py b/mail/src/leap/mail/smtp/tests/test_gateway.py
index 25c780e1..f9ea027c 100644
--- a/mail/src/leap/mail/smtp/tests/test_smtprelay.py
+++ b/mail/src/leap/mail/smtp/tests/test_gateway.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# test_smtprelay.py
+# test_gateway.py
# Copyright (C) 2013 LEAP
#
# This program is free software: you can redistribute it and/or modify
@@ -17,7 +17,7 @@
"""
-SMTP relay tests.
+SMTP gateway tests.
"""
@@ -33,7 +33,7 @@ from twisted.mail.smtp import (
)
from mock import Mock
-from leap.mail.smtp.smtprelay import (
+from leap.mail.smtp.gateway import (
SMTPFactory,
EncryptedMessage,
)
@@ -52,9 +52,9 @@ HOSTNAME_REGEX = "(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*" + \
IP_OR_HOST_REGEX = '(' + IP_REGEX + '|' + HOSTNAME_REGEX + ')'
-class TestSmtpRelay(TestCaseWithKeyManager):
+class TestSmtpGateway(TestCaseWithKeyManager):
- EMAIL_DATA = ['HELO relay.leap.se',
+ EMAIL_DATA = ['HELO gateway.leap.se',
'MAIL FROM: <%s>' % ADDRESS_2,
'RCPT TO: <%s>' % ADDRESS,
'DATA',
@@ -90,7 +90,7 @@ class TestSmtpRelay(TestCaseWithKeyManager):
self.assertEqual(text, decrypted,
"Decrypted text differs from plaintext.")
- def test_relay_accepts_valid_email(self):
+ def test_gateway_accepts_valid_email(self):
"""
Test if SMTP server responds correctly for valid interaction.
"""
@@ -112,7 +112,7 @@ class TestSmtpRelay(TestCaseWithKeyManager):
proto.lineReceived(line + '\r\n')
self.assertMatch(transport.value(),
'\r\n'.join(SMTP_ANSWERS[0:i + 1]),
- 'Did not get expected answer from relay.')
+ 'Did not get expected answer from gateway.')
proto.setTimeout(None)
def test_message_encrypt(self):
@@ -124,7 +124,7 @@ class TestSmtpRelay(TestCaseWithKeyManager):
self._config['cert'], self._config['key'],
self._config['encrypted_only']).buildProtocol(('127.0.0.1', 0))
fromAddr = Address(ADDRESS_2)
- dest = User(ADDRESS, 'relay.leap.se', proto, ADDRESS)
+ dest = User(ADDRESS, 'gateway.leap.se', proto, ADDRESS)
m = EncryptedMessage(
fromAddr, dest, self._km, self._config['host'],
self._config['port'], self._config['cert'], self._config['key'])
@@ -159,7 +159,7 @@ class TestSmtpRelay(TestCaseWithKeyManager):
self._km, self._config['host'], self._config['port'],
self._config['cert'], self._config['key'],
self._config['encrypted_only']).buildProtocol(('127.0.0.1', 0))
- user = User(ADDRESS, 'relay.leap.se', proto, ADDRESS)
+ user = User(ADDRESS, 'gateway.leap.se', proto, ADDRESS)
fromAddr = Address(ADDRESS_2)
m = EncryptedMessage(
fromAddr, user, self._km, self._config['host'],
@@ -199,7 +199,7 @@ class TestSmtpRelay(TestCaseWithKeyManager):
self._km, self._config['host'], self._config['port'],
self._config['cert'], self._config['key'],
self._config['encrypted_only']).buildProtocol(('127.0.0.1', 0))
- user = User('ihavenopubkey@nonleap.se', 'relay.leap.se', proto, ADDRESS)
+ user = User('ihavenopubkey@nonleap.se', 'gateway.leap.se', proto, ADDRESS)
fromAddr = Address(ADDRESS_2)
m = EncryptedMessage(
fromAddr, user, self._km, self._config['host'],