From 139e141e1ef41095d2e08ad0566dd415495f653f Mon Sep 17 00:00:00 2001
From: Stuart Gathman <stuart@gathman.org>
Date: Fri, 5 Jan 2007 23:33:55 +0000
Subject: [PATCH] Make blacklist an AddrCache
---
Milter/cache.py | 5 +++++
bms.py | 11 ++++++-----
milter.spec | 3 +++
testcache.py | 1 +
4 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/Milter/cache.py b/Milter/cache.py
index 94df3b1..8de1fcf 100644
--- a/Milter/cache.py
+++ b/Milter/cache.py
@@ -10,6 +10,9 @@
# CBV results.
#
# $Log$
+# Revision 1.1 2007/01/05 21:25:40 customdesigned
+# Move AddrCache to Milter package.
+#
# Author: Stuart D. Gathman <stuart@bmsi.com>
# Copyright 2001,2002,2003,2004,2005 Business Management Systems, Inc.
@@ -68,6 +71,8 @@ class AddrCache(object):
pass
return False
+ __contains__ = has_key
+
def __getitem__(self,sender):
try:
lsender = sender.lower()
diff --git a/bms.py b/bms.py
index c102f2f..9a430a5 100644
--- a/bms.py
+++ b/bms.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# A simple milter that has grown quite a bit.
# $Log$
+# Revision 1.80 2007/01/05 23:12:12 customdesigned
+# Move parse_addr, iniplist, ip4re to Milter.utils
+#
# Revision 1.79 2007/01/05 21:25:40 customdesigned
# Move AddrCache to Milter package.
#
@@ -466,13 +469,11 @@ class SPFPolicy(object):
from Milter.cache import AddrCache
cbv_cache = AddrCache(renew=7)
-cbv_cache.load('send_dsn.log',age=7)
+cbv_cache.load('send_dsn.log',age=30)
auto_whitelist = AddrCache(renew=30)
auto_whitelist.load('auto_whitelist.log',age=120)
-try:
- blacklist = set(open('blacklist.log').read().split())
-except:
- blacklist = {}
+blacklist = AddrCache(renew=30)
+blacklist.load('blacklist.log',age=60)
class bmsMilter(Milter.Milter):
"""Milter to replace attachments poisonous to Windows with a WARNING message,
diff --git a/milter.spec b/milter.spec
index 4da9f8b..875f16b 100644
--- a/milter.spec
+++ b/milter.spec
@@ -176,6 +176,9 @@ rm -rf $RPM_BUILD_ROOT
/usr/share/sendmail-cf/hack/rhsbl.m4
%changelog
+* Fri Jan 05 2007 Stuart Gathman <stuart@bmsi.com> 0.8.8-1
+- Move AddrCache, parse_addr, iniplist to Milter package
+- add sample spfmilter.py milter
* Sat Nov 04 2006 Stuart Gathman <stuart@bmsi.com> 0.8.7-1
- More lame bounce heuristics
- SPF moved to pyspf RPM
diff --git a/testcache.py b/testcache.py
index e14ca95..a3cd9ec 100644
--- a/testcache.py
+++ b/testcache.py
@@ -19,6 +19,7 @@ class AddrCacheTestCase(unittest.TestCase):
cache['temp@bar.com'] = 'testing'
self.failUnless(cache.has_key('foo@bar.com'))
self.failUnless(not cache.has_key('hello@bar.com'))
+ self.failUnless('baz@bar.com' in cache)
self.assertEquals(cache['temp@bar.com'],'testing')
s = open(self.fname).readlines()
self.failUnless(len(s) == 2)
--
GitLab