From: John E H. <jh...@ti...> - 2006-10-24 17:50:21
|
Below is a patch against the pyzor plugin in SpamAssassin 3.1.6 It loops over the responses from 'pyzor check' and picks the max. Thanks to Milton's server and this patch, SA is using pyzor effectively again to contribute to the spam score. If you do put more than one server in ~/.pyzor/servers, you should also either lengthen the SA timeout (pyzor_timeout) from the default 5... or shorten the default pyzor timeout of 5. I did the latter: % cat ~/.pyzor/servers 82.94.255.100:24441 66.250.40.33:24441 % cat ~/.pyzor/config [client] ServersFile = servers Timeout = 3 So when 66.* times out (which it does a lot as many people on this list have observed), it won't cause SA to invalidate other legit responses from other servers by making SA time out waiting for the slow server. This patch has some extra debug in it and was intentionally not re-indented in order to highlight just the substantive changes. If it goes into SA, - fix it to conform to the right indent/coding style and be less hacky - possibly consider a different algorithm than "pick the max count from all responding servers" - change the default plugin timeout to be a bit more than the default pyzor timeout. --- lib/Mail/SpamAssassin/Plugin/Pyzor.pm.orig Fri Sep 29 07:06:39 2006 +++ lib/Mail/SpamAssassin/Plugin/Pyzor.pm Tue Oct 24 11:32:30 2006 @@ -229,7 +229,10 @@ my ($self, $permsgstatus, $fulltext) = @_; my @response; my $pyzor_count; + my $pyzor_respcount; my $pyzor_whitelisted; + my $i; + my $sz; my $timeout = $self->{main}->{conf}->{pyzor_timeout}; $pyzor_count = 0; @@ -302,16 +305,29 @@ return 0; } + $pyzor_respcount = 0; + $sz = @response; + for ($i = 0; $i < $sz; $i++) { + dbg("pyzor: response $i: \"$response[$i]\", respcnt: $pyzor_respcount, count: $pyzor_count, resp sz: $sz"); # this regexp is intended to be a little bit forgiving - if ($response[0] =~ /^\S+\t.*?\t(\d+)\t(\d+)\s*$/) { + if ($response[$i] =~ /^\S+\t.*?\t(\d+)\t(\d+)\s*$/) { $pyzor_whitelisted = $2+0; if ($pyzor_whitelisted == 0) { - $pyzor_count = $1+0; + # Pick max count from all server responses + if ($pyzor_count < $1+0) { + $pyzor_count = $1+0; + } + $pyzor_respcount++; } + dbg("pyzor: response $i,2: \"$response[$i]\", respcnt: $pyzor_respcount, count: $pyzor_count"); } else { # warn on failures to parse - dbg("pyzor: failure to parse response \"$response[0]\""); + dbg("pyzor: failure to parse response \"$response[$i]\""); + } + } + if ($pyzor_respcount > 0) { + dbg("pyzor: final count: $pyzor_count"); } if ($pyzor_whitelisted) { |