Make blacklist an AddrCache
This commit is contained in:
@@ -10,6 +10,9 @@
|
|||||||
# CBV results.
|
# CBV results.
|
||||||
#
|
#
|
||||||
# $Log$
|
# $Log$
|
||||||
|
# Revision 1.1 2007/01/05 21:25:40 customdesigned
|
||||||
|
# Move AddrCache to Milter package.
|
||||||
|
#
|
||||||
|
|
||||||
# Author: Stuart D. Gathman <stuart@bmsi.com>
|
# Author: Stuart D. Gathman <stuart@bmsi.com>
|
||||||
# Copyright 2001,2002,2003,2004,2005 Business Management Systems, Inc.
|
# Copyright 2001,2002,2003,2004,2005 Business Management Systems, Inc.
|
||||||
@@ -68,6 +71,8 @@ class AddrCache(object):
|
|||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
__contains__ = has_key
|
||||||
|
|
||||||
def __getitem__(self,sender):
|
def __getitem__(self,sender):
|
||||||
try:
|
try:
|
||||||
lsender = sender.lower()
|
lsender = sender.lower()
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# A simple milter that has grown quite a bit.
|
# A simple milter that has grown quite a bit.
|
||||||
# $Log$
|
# $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
|
# Revision 1.79 2007/01/05 21:25:40 customdesigned
|
||||||
# Move AddrCache to Milter package.
|
# Move AddrCache to Milter package.
|
||||||
#
|
#
|
||||||
@@ -466,13 +469,11 @@ class SPFPolicy(object):
|
|||||||
from Milter.cache import AddrCache
|
from Milter.cache import AddrCache
|
||||||
|
|
||||||
cbv_cache = AddrCache(renew=7)
|
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 = AddrCache(renew=30)
|
||||||
auto_whitelist.load('auto_whitelist.log',age=120)
|
auto_whitelist.load('auto_whitelist.log',age=120)
|
||||||
try:
|
blacklist = AddrCache(renew=30)
|
||||||
blacklist = set(open('blacklist.log').read().split())
|
blacklist.load('blacklist.log',age=60)
|
||||||
except:
|
|
||||||
blacklist = {}
|
|
||||||
|
|
||||||
class bmsMilter(Milter.Milter):
|
class bmsMilter(Milter.Milter):
|
||||||
"""Milter to replace attachments poisonous to Windows with a WARNING message,
|
"""Milter to replace attachments poisonous to Windows with a WARNING message,
|
||||||
|
|||||||
@@ -176,6 +176,9 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
/usr/share/sendmail-cf/hack/rhsbl.m4
|
/usr/share/sendmail-cf/hack/rhsbl.m4
|
||||||
|
|
||||||
%changelog
|
%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
|
* Sat Nov 04 2006 Stuart Gathman <stuart@bmsi.com> 0.8.7-1
|
||||||
- More lame bounce heuristics
|
- More lame bounce heuristics
|
||||||
- SPF moved to pyspf RPM
|
- SPF moved to pyspf RPM
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class AddrCacheTestCase(unittest.TestCase):
|
|||||||
cache['temp@bar.com'] = 'testing'
|
cache['temp@bar.com'] = 'testing'
|
||||||
self.failUnless(cache.has_key('foo@bar.com'))
|
self.failUnless(cache.has_key('foo@bar.com'))
|
||||||
self.failUnless(not cache.has_key('hello@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')
|
self.assertEquals(cache['temp@bar.com'],'testing')
|
||||||
s = open(self.fname).readlines()
|
s = open(self.fname).readlines()
|
||||||
self.failUnless(len(s) == 2)
|
self.failUnless(len(s) == 2)
|
||||||
|
|||||||
Reference in New Issue
Block a user