On Thu, May 12, 2005 at 11:36:22AM +0100, Nik Clayton wrote: > Ditch mimedefang-filter. Have mimedefang.pl use something like > Module::Pluggable to find everything in the MimeDefang::Filter::Plugin > namespace. > > Then have every filter_* subroutine in mimedefang-filter be something like:
Hm. So all the fun happens on this list while I'm temporarily away :) This is precisely the thing I ran into when we started building our MIMEDefang filters, so I just went ahead and created a way to modularize the mimedefang-filter. As an example, I've rewritten suggested-minimum-filter-for-windows-clients into separate modules, and made that available here: http://www.xs4all.nl/~johnpc/mimedefang-modular/ (note that the example was done rather quickly, and without too much testing. For example this still contains a (C) Roaring Penguin... which is not too strange since a large part is a literal copy of the example filter. The example primairily serves as a coding example). The heart of this is a mimedefang-filter-select file, which acts as a replacement to mimedefang-filter. It does exactly what you describe: loop over all modules for all filter_* calls... except that modules that "take action" obviously abort the loop. Since this installs as a replacement "mimedefang-filter", this requires no changes to mimedefang itself, so you can still install mimedefang upgrades when necessary. This also uses a module "Mimedefang.pm" which makes Mimedefang appear like a regular perl module/namespace that allows you to import symbols from. Somewhat hackish, but all the complexity is compile-time complexity and therefore hardly worth looking at. All the filters are stored in the MailFilter/ subdirectory, all filters reside in the MailFilter::* namespace. MailFilter::Settings is hardcoded in mimedefang-filter-select, and contains the list of modules to use. This works, rather well even, because it allows us to have multiple developers working on different parts of the filter without conflicts, and it allows for easier testing. I haven't yet made a real independent test-setup yet, but at least you can install one module on, say, your desktop machine and telnet to localhost:25 to test it. Anyone is free to use this, it can be distributed with the same conditions as MIMEDefang itself. We're using it ourselves, on production systems handling millions of emails per day (at least the mimedefang-filter- select and Mimedefang.pm, not the rest of the example). However, this isn't fully complete, for example filter_map is missing. Also, I might change the naming scheme at any point since I'm not too happy about the MailFilter:: namespace (and CPAN maintainers would likely kill me for using that). However, since I'm using this myself, any renaming will likely only require a few well chosen global search/replace actions on your custom filters, to get updated. Also, please notice: this adds a lot of "scary perl" to your mimedefang filter. If you're intimidated by the perl in suggested-minimum-filter-for- windows-clients, then this is probably not for you. Feedback is welcome. I can't promise to implement all suggestions, but I'll definately consider good ones (and I get to decide which suggestions are good :) -- #!perl -wpl # mmfppfmpmmpp mmpffm <[EMAIL PROTECTED]> $p=3-2*/[^\W\dmpf_]/i;s.[a-z]{$p}.vec($f=join('',$p-1?chr(sub{$_[0]*9+$_[1]*3+ $_[2]}->(map{/p|f/i+/f/i}split//,$&)+97):qw(m p f)[map{((ord$&)%32-1)/$_%3}(9, 3,1)]),5,1)='`'lt$&;$f.eig; # Jan-Pieter Cornet _______________________________________________ Visit http://www.mimedefang.org and http://www.canit.ca MIMEDefang mailing list [email protected] http://lists.roaringpenguin.com/mailman/listinfo/mimedefang

