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 | 4fa3d27225f44d9598d24d9e59a97baaa9bbb90e (patch) | |
tree | 148f46cee12badce78819427819a11e0b04096c6 /src/leap/mail | |
parent | 22f619cf2a295ecc5beff16a91de63728ac4b17d (diff) |
make outgoing a new submodule
Diffstat (limited to 'src/leap/mail')
-rw-r--r-- | src/leap/mail/outgoing/__init__.py | 0 | ||||
-rw-r--r-- | src/leap/mail/outgoing/service.py (renamed from src/leap/mail/service.py) | 13 | ||||
-rw-r--r-- | src/leap/mail/outgoing/tests/__init__.py | 0 | ||||
-rw-r--r-- | src/leap/mail/outgoing/tests/test_outgoing.py (renamed from src/leap/mail/tests/test_service.py) | 2 | ||||
-rw-r--r-- | src/leap/mail/smtp/__init__.py | 2 | ||||
-rw-r--r-- | src/leap/mail/smtp/gateway.py | 6 | ||||
-rw-r--r-- | src/leap/mail/walk.py | 64 |
7 files changed, 45 insertions, 42 deletions
diff --git a/src/leap/mail/outgoing/__init__.py b/src/leap/mail/outgoing/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/leap/mail/outgoing/__init__.py diff --git a/src/leap/mail/service.py b/src/leap/mail/outgoing/service.py index a99f13a..b70b3b1 100644 --- a/src/leap/mail/service.py +++ b/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/src/leap/mail/outgoing/tests/__init__.py b/src/leap/mail/outgoing/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/leap/mail/outgoing/tests/__init__.py diff --git a/src/leap/mail/tests/test_service.py b/src/leap/mail/outgoing/tests/test_outgoing.py index 43f354d..fa50c30 100644 --- a/src/leap/mail/tests/test_service.py +++ b/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/src/leap/mail/smtp/__init__.py b/src/leap/mail/smtp/__init__.py index 72b26ed..24402b4 100644 --- a/src/leap/mail/smtp/__init__.py +++ b/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/src/leap/mail/smtp/gateway.py b/src/leap/mail/smtp/gateway.py index d58c581..222ef3f 100644 --- a/src/leap/mail/smtp/gateway.py +++ b/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/src/leap/mail/walk.py b/src/leap/mail/walk.py index f747377..5172837 100644 --- a/src/leap/mail/walk.py +++ b/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 ;) -""" |