[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/develop] Remove superfluous normalizeEmail() call.



commit c20c6a866c0b766a7f4ebbb1bce4622d933d7f12
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Mon Jun 9 19:51:30 2014 +0000

    Remove superfluous normalizeEmail() call.
    
     * REMOVE second call to normalizeEmail() in
       EmailBasedDistributor.getBridgesForEmail(), and add note about where the
       checks are currently called.
    
     * ADD some extra logging when we receive imcoming requests from email
       addresses in the EMAIL_WHITELIST.
    
     * TODO check that incoming emails from addresses in EMAIL_WHITELIST have
       valid signatures made by the key with the corresponding GnuPG key
       fingerprint (as in EMAIL_WHITELIST, which is a mapping of addresses to
       fingerprints).
---
 lib/bridgedb/Dist.py |   23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/lib/bridgedb/Dist.py b/lib/bridgedb/Dist.py
index 0ba2233..df1ce5b 100644
--- a/lib/bridgedb/Dist.py
+++ b/lib/bridgedb/Dist.py
@@ -404,16 +404,13 @@ class EmailBasedDistributor(Distributor):
             bridgeFilterRules=[]
         now = time.time()
 
-        emailaddr = None
-        try:
-            emailaddr = addr.normalizeEmail(emailaddress,
-                                            self.domainmap,
-                                            self.domainrules)
-            if not emailaddr:
-                raise addr.BadEmail("Couldn't normalize email address: %r"
-                                    % emailaddress)
-        except addr.BadEmail as error:
-            logging.warn(error)
+        # All checks on the email address, such as checks for whitelisting and
+        # canonicalization of domain name, are done in
+        # :meth:`bridgedb.email.autoresponder.getMailTo` and
+        # :meth:`bridgedb.email.autoresponder.SMTPAutoresponder.runChecks`.
+        if not emailaddress:
+            logging.error(("%s distributor can't get bridges for blank email "
+                           "address!") % (self.name, emailaddress))
             return []
 
         with bridgedb.Storage.getDB() as db:
@@ -424,7 +421,11 @@ class EmailBasedDistributor(Distributor):
                          % (N, emailaddress))
 
             if lastSaw is not None:
-                if (lastSaw + MAX_EMAIL_RATE) >= now:
+                if emailaddress in self.whitelist.keys():
+                    logging.info(("Whitelisted email address %s was last seen "
+                                  "%d seconds ago.")
+                                 % (emailaddress, now - lastSaw))
+                elif (lastSaw + MAX_EMAIL_RATE) >= now:
                     wait = (lastSaw + MAX_EMAIL_RATE) - now
                     logging.info("Client %s must wait another %d seconds."
                                  % (emailaddress, wait))



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits