CVS: tmda/TMDA Address.py,1.5,1.6 FilterParser.py,1.61,1.62

"Jason R. Mastaler" <[email protected]>
Newsgroups gmane.mail.spam.tmda.cvs
Message-ID <[email protected]>
Update of /cvsroot/tmda/tmda/TMDA
In directory sc8-pr-cvs1:/tmp/cvs-serv569/TMDA

Modified Files:
	Address.py FilterParser.py 
Log Message:
New feature from Ed Blackman.  'sender' style tagged addresses have
been enhanced to check entire domains instead of just a full e-mail
address.  Thus, you can generate a tagged address that will accept
mail from [email protected], [email protected], or even anyone@tld.

You can generate such tagged addresses using tmda-address, the new
'domain' action in your FILTER_OUTGOING file, or 'X-TMDA: domain'.
See http://us.tmda.net/config-filter.html for more info.

Also see http://mla.libertine.org/tmda-workers/2003-08/msg00145.html
for a detailed description of how this new feature works.


Index: Address.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/Address.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Address.py	25 Jun 2003 05:29:13 -0000	1.5
+++ Address.py	2 Sep 2003 03:53:52 -0000	1.6
@@ -201,11 +201,24 @@
         self.address = tagged_local + '@' + domain
         return self
 
+    # Try to match against the HMAC generated from the full sender first.
+    # If that doesn't match, try to match against the full domain, removing
+    # domain parts (eg, 'foo.example.com' => 'example.com') until there's a
+    # match or there are no more parts left.
     def verify(self, sender):
+        sender = str(sender).lower()
         hmac = self.local_parts[-1]
-        try_hmac = Cookie.make_sender_cookie(str(sender).lower())
+        try_hmac = Cookie.make_sender_cookie(sender)
         if try_hmac != hmac:
-            raise BadCryptoError, "Invalid cryptographic tag."
+            domain = sender.split('@')[-1]
+            dot = '.'
+            domain_parts = domain.split(dot)
+
+            while try_hmac != hmac and domain_parts:
+              try_hmac = Cookie.make_sender_cookie(dot.join(domain_parts))
+              del domain_parts[0]
+            if try_hmac != hmac:
+              raise BadCryptoError, "Invalid cryptographic tag."
 
     def hmac(self):
         return self.local_parts[-1]

Index: FilterParser.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/FilterParser.py,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- FilterParser.py	20 Aug 2003 00:28:03 -0000	1.61
+++ FilterParser.py	2 Sep 2003 03:53:52 -0000	1.62
@@ -251,7 +251,7 @@
     """, re.VERBOSE | re.IGNORECASE)
     
     out_action = re.compile(r"""
-    ( (?:(?:bare|sender|dated)(?:=\S+)?)
+    ( (?:(?:bare|sender|domain|dated)(?:=\S+)?)
     | (?:(?:exp(?:licit)?|as|ext(?:ension)?|kw|keyword)=\S+)
     | default )""", re.VERBOSE | re.IGNORECASE)
     

_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.