[tor-commits] [gettor/master] Add missing `filters.py' file ;)

kaner at torproject.org kaner at torproject.org
Thu Feb 24 19:12:00 UTC 2011


commit 85e5a4053f2aa514a6d50af9447b906cb6bf67ce
Author: Christian Fromme <kaner at strace.org>
Date:   Tue Feb 22 03:20:59 2011 +0100

    Add missing `filters.py' file ;)
---
 lib/gettor/filters.py |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/lib/gettor/filters.py b/lib/gettor/filters.py
new file mode 100644
index 0000000..558e945
--- /dev/null
+++ b/lib/gettor/filters.py
@@ -0,0 +1,45 @@
+# Copyright (c) 2008 - 2011, Jacob Appelbaum <jacob at appelbaum.net>, 
+#                            Christian Fromme <kaner at strace.org>
+#  This is Free Software. See LICENSE for license information.
+
+import re
+import logging 
+
+def doFilter(reqInfo):
+    """DOCDOC
+    """
+    reqInfo['package'] = doPackageHacks(reqInfo['package'], reqInfo['locale']) 
+    reqInfo['valid'] = checkAddressHack(reqInfo['user'])
+
+    return reqInfo
+
+def doPackageHacks(packageName, locale):
+    """If someone wants one of the localizable packages, add language 
+       suffix. This isn't nice because we're hard-coding package names here
+       Attention: This needs to correspond to the  packages in packages.py
+    """
+    if packageName == "tor-browser-bundle" \
+           or packageName == "tor-im-browser-bundle" \
+           or packageName == "linux-browser-bundle-i386" \
+           or packageName == "linux-browser-bundle-x86_64":
+        # "tor-browser-bundle" => "tor-browser-bundle_de"
+        packageName += "_" + locale
+
+    return packageName
+
+def checkAddressHack(userAddress):
+    """This makes it possible to add hardcoded blacklist entries *ugh*
+       XXX: This should merge somehow with the GetTor blacklisting
+            mechanism at some point
+    """
+    logging.debug("Checking user address %s.." % userAddress)
+    if re.compile(".*@.*torproject.org.*").match(userAddress):
+        return False
+        
+    # Make sure we drop bounce mails
+    if userAddress == "<>":
+        logging.debug("We've received a bounce")
+        return False
+
+    # User address looks good.
+    return True





More information about the tor-commits mailing list