diff options
author | Kali Kaneko <kali@leap.se> | 2015-01-02 10:58:43 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-02-11 14:05:43 -0400 |
commit | a5b725cda14074613193f793b76ccb4ea5a8a2a3 (patch) | |
tree | d075328923a617687aa4bf490db2da58537abcf7 /mail/src/leap | |
parent | 1def95cc42d12978a904f139badbfa11e1fceeec (diff) |
make outgoing a new submodule
Diffstat (limited to 'mail/src/leap')
-rw-r--r-- | mail/src/leap/mail/outgoing/__init__.py | 0 | ||||
-rw-r--r-- | mail/src/leap/mail/outgoing/service.py (renamed from mail/src/leap/mail/service.py) | 13 | ||||
-rw-r--r-- | mail/src/leap/mail/outgoing/tests/__init__.py | 0 | ||||
-rw-r--r-- | mail/src/leap/mail/outgoing/tests/test_outgoing.py (renamed from mail/src/leap/mail/tests/test_service.py) | 2 | ||||
-rw-r--r-- | mail/src/leap/mail/smtp/__init__.py | 2 | ||||
-rw-r--r-- | mail/src/leap/mail/smtp/gateway.py | 6 | ||||
-rw-r--r-- | mail/src/leap/mail/walk.py | 64 |
7 files changed, 45 insertions, 42 deletions
diff --git a/mail/src/leap/mail/outgoing/__init__.py b/mail/src/leap/mail/outgoing/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/mail/src/leap/mail/outgoing/__init__.py diff --git a/mail/src/leap/mail/service.py b/mail/src/leap/mail/outgoing/service.py index a99f13a9..b70b3b10 100644 --- a/mail/src/leap/mail/service.py +++ b/mail/src/leap/mail/outgoing/service.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# service.py -# Copyright (C) 2013 LEAP +# outgoing/service.py +# Copyright (C) 2013-2015 LEAP # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -41,6 +41,10 @@ from leap.mail.smtp.rfc3156 import RFC3156CompliantGenerator from leap.mail.smtp.rfc3156 import PGPSignature from leap.mail.smtp.rfc3156 import PGPEncrypted +# TODO +# [ ] rename this module to something else, service should be the implementor +# of IService + class SSLContextFactory(ssl.ClientContextFactory): def __init__(self, cert, key): @@ -48,6 +52,9 @@ class SSLContextFactory(ssl.ClientContextFactory): self.key = key def getContext(self): + # FIXME -- we should use sslv23 to allow for tlsv1.2 + # and, if possible, explicitely disable sslv3 clientside. + # Servers should avoid sslv3 self.method = SSL.TLSv1_METHOD # SSLv23_METHOD ctx = ssl.ClientContextFactory.getContext(self) ctx.use_certificate_file(self.cert) @@ -57,7 +64,7 @@ class SSLContextFactory(ssl.ClientContextFactory): class OutgoingMail: """ - A service for handling encrypted mail. + A service for handling encrypted outgoing mail. """ FOOTER_STRING = "I prefer encrypted email" diff --git a/mail/src/leap/mail/outgoing/tests/__init__.py b/mail/src/leap/mail/outgoing/tests/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/mail/src/leap/mail/outgoing/tests/__init__.py diff --git a/mail/src/leap/mail/tests/test_service.py b/mail/src/leap/mail/outgoing/tests/test_outgoing.py index 43f354d6..fa50c305 100644 --- a/mail/src/leap/mail/tests/test_service.py +++ b/mail/src/leap/mail/outgoing/tests/test_outgoing.py @@ -28,7 +28,7 @@ from twisted.mail.smtp import User from mock import Mock from leap.mail.smtp.gateway import SMTPFactory -from leap.mail.service import OutgoingMail +from leap.mail.outgoing.service import OutgoingMail from leap.mail.tests import ( TestCaseWithKeyManager, ADDRESS, diff --git a/mail/src/leap/mail/smtp/__init__.py b/mail/src/leap/mail/smtp/__init__.py index 72b26ed9..24402b4c 100644 --- a/mail/src/leap/mail/smtp/__init__.py +++ b/mail/src/leap/mail/smtp/__init__.py @@ -22,7 +22,7 @@ import logging from twisted.internet import reactor from twisted.internet.error import CannotListenError -from leap.mail.service import OutgoingMail +from leap.mail.outgoing.service import OutgoingMail logger = logging.getLogger(__name__) diff --git a/mail/src/leap/mail/smtp/gateway.py b/mail/src/leap/mail/smtp/gateway.py index d58c581b..222ef3f5 100644 --- a/mail/src/leap/mail/smtp/gateway.py +++ b/mail/src/leap/mail/smtp/gateway.py @@ -93,7 +93,7 @@ class SMTPFactory(ServerFactory): mail or not. :type encrypted_only: bool :param outgoing_mail: The outgoing mail to send the message - :type outgoing_mail: leap.mail.service.OutgoingMail + :type outgoing_mail: leap.mail.outgoing.service.OutgoingMail """ leap_assert_type(encrypted_only, bool) @@ -141,7 +141,7 @@ class SMTPDelivery(object): mail or not. :type encrypted_only: bool :param outgoing_mail: The outgoing mail to send the message - :type outgoing_mail: leap.mail.service.OutgoingMail + :type outgoing_mail: leap.mail.outgoing.service.OutgoingMail """ self._userid = userid self._outgoing_mail = outgoing_mail @@ -266,7 +266,7 @@ class EncryptedMessage(object): :param user: The recipient of this message. :type user: twisted.mail.smtp.User :param outgoing_mail: The outgoing mail to send the message - :type outgoing_mail: leap.mail.service.OutgoingMail + :type outgoing_mail: leap.mail.outgoing.service.OutgoingMail """ # assert params leap_assert_type(user, smtp.User) diff --git a/mail/src/leap/mail/walk.py b/mail/src/leap/mail/walk.py index f747377a..51728378 100644 --- a/mail/src/leap/mail/walk.py +++ b/mail/src/leap/mail/walk.py @@ -85,6 +85,35 @@ get_raw_docs = lambda msg, parts: ( for payload, headers in get_payloads(msg) if not isinstance(payload, list)) +""" +Groucho Marx: Now pay particular attention to this first clause, because it's + most important. There's the party of the first part shall be + known in this contract as the party of the first part. How do you + like that, that's pretty neat eh? + +Chico Marx: No, that's no good. +Groucho Marx: What's the matter with it? + +Chico Marx: I don't know, let's hear it again. +Groucho Marx: So the party of the first part shall be known in this contract as + the party of the first part. + +Chico Marx: Well it sounds a little better this time. +Groucho Marx: Well, it grows on you. Would you like to hear it once more? + +Chico Marx: Just the first part. +Groucho Marx: All right. It says the first part of the party of the first part + shall be known in this contract as the first part of the party of + the first part, shall be known in this contract - look, why + should we quarrel about a thing like this, we'll take it right + out, eh? + +Chico Marx: Yes, it's too long anyhow. Now what have we got left? +Groucho Marx: Well I've got about a foot and a half. Now what's the matter? + +Chico Marx: I don't like the second party either. +""" + def walk_msg_tree(parts, body_phash=None): """ @@ -162,7 +191,7 @@ def walk_msg_tree(parts, body_phash=None): outer = parts[0] outer.pop(HEADERS) - if not PART_MAP in outer: + if PART_MAP not in outer: # we have a multipart with 1 part only, so kind of fix it # although it would be prettier if I take this special case at # the beginning of the walk. @@ -177,36 +206,3 @@ def walk_msg_tree(parts, body_phash=None): pdoc = outer pdoc[BODY] = body_phash return pdoc - -""" -Groucho Marx: Now pay particular attention to this first clause, because it's - most important. There's the party of the first part shall be - known in this contract as the party of the first part. How do you - like that, that's pretty neat eh? - -Chico Marx: No, that's no good. -Groucho Marx: What's the matter with it? - -Chico Marx: I don't know, let's hear it again. -Groucho Marx: So the party of the first part shall be known in this contract as - the party of the first part. - -Chico Marx: Well it sounds a little better this time. -Groucho Marx: Well, it grows on you. Would you like to hear it once more? - -Chico Marx: Just the first part. -Groucho Marx: All right. It says the first part of the party of the first part - shall be known in this contract as the first part of the party of - the first part, shall be known in this contract - look, why - should we quarrel about a thing like this, we'll take it right - out, eh? - -Chico Marx: Yes, it's too long anyhow. Now what have we got left? -Groucho Marx: Well I've got about a foot and a half. Now what's the matter? - -Chico Marx: I don't like the second party either. -""" - -""" -I feel you deserved it after reading the above and try to debug your problem ;) -""" |