1 |
diff -Nur -x '*.orig' -x '*.rej' qpsmtpd-0.96/config.sample/karma_tlds mezzanine_patched_qpsmtpd-0.96/config.sample/karma_tlds |
2 |
--- qpsmtpd-0.96/config.sample/karma_tlds 1970-01-01 01:00:00.000000000 +0100 |
3 |
+++ mezzanine_patched_qpsmtpd-0.96/config.sample/karma_tlds 2016-04-20 20:44:35.881444632 +0200 |
4 |
@@ -0,0 +1,14 @@ |
5 |
+# Karma to apply depending on the tld of the envelope sender |
6 |
+# Used by the karma plugin |
7 |
+# Warning: setting karma too low can blacklist the entire tld |
8 |
+work:-4 |
9 |
+rocks:-3 |
10 |
+ninja:-3 |
11 |
+info:-2 |
12 |
+biz:-2 |
13 |
+pw:-2 |
14 |
+me:-1 |
15 |
+us:-5 |
16 |
+eu:-4 |
17 |
+link:-3 |
18 |
+science:-6 |
19 |
diff -Nur -x '*.orig' -x '*.rej' qpsmtpd-0.96/plugins/karma mezzanine_patched_qpsmtpd-0.96/plugins/karma |
20 |
--- qpsmtpd-0.96/plugins/karma 2016-04-20 20:44:38.326444593 +0200 |
21 |
+++ mezzanine_patched_qpsmtpd-0.96/plugins/karma 2016-04-20 19:18:31.922041433 +0200 |
22 |
@@ -102,6 +102,20 @@ |
23 |
|
24 |
Adjust the quantity of logging for this plugin. See docs/logging.pod |
25 |
|
26 |
+=head1 CONFIG FILES |
27 |
+ |
28 |
+This plugin uses the following configuration files. All are optional. |
29 |
+ |
30 |
+=head2 karma_tlds |
31 |
+ |
32 |
+This file can contain semicolon separated tld and the corresponding |
33 |
+karma adjustment to apply when the envelope sender match. It can be used to |
34 |
+penalize "spammy" tlds, or to raise the karma from (mostly) good tlds. |
35 |
+ |
36 |
+jp:-4 |
37 |
+ch:-3 |
38 |
+fr:+1 |
39 |
+ |
40 |
=head1 BENEFITS |
41 |
|
42 |
Karma reduces the resources wasted by naughty mailers. When used with |
43 |
@@ -352,18 +366,14 @@ |
44 |
my $full_from = $self->connection->notes('envelope_from'); |
45 |
$self->illegal_envelope_format( $full_from ); |
46 |
|
47 |
- my %spammy_tlds = ( |
48 |
- map { $_ => 4 } qw/ info pw /, |
49 |
- map { $_ => 3 } qw/ tw biz /, |
50 |
- map { $_ => 2 } qw/ cl br fr be jp no se sg /, |
51 |
- ); |
52 |
- foreach my $tld ( keys %spammy_tlds ) { |
53 |
+ my $karma_tlds = $self->get_karma_tlds() or return DECLINED; |
54 |
+ foreach my $tld ( keys %$karma_tlds ) { |
55 |
my $len = length $tld; |
56 |
- my $score = $spammy_tlds{$tld} or next; |
57 |
+ my $score = $karma_tlds->{$tld} or next; |
58 |
$len ++; |
59 |
if ( $sender->host && ".$tld" eq substr($sender->host,-$len,$len) ) { |
60 |
- $self->log(LOGINFO, "penalizing .$tld envelope sender"); |
61 |
- $self->adjust_karma(-$score); |
62 |
+ $self->log(LOGINFO, "adjusting karma for .$tld envelope sender"); |
63 |
+ $self->adjust_karma($score); |
64 |
} |
65 |
} |
66 |
|
67 |
@@ -479,6 +489,19 @@ |
68 |
} |
69 |
} |
70 |
|
71 |
+sub get_karma_tlds { |
72 |
+ my $self = shift; |
73 |
+ |
74 |
+ my %karma_tlds = |
75 |
+ map { (split /:/, $_, 2)[0, 1] } $self->qp->config('karma_tlds'); |
76 |
+ if (!%karma_tlds) { |
77 |
+ $self->log(LOGDEBUG, "no specific karma for tlds defined"); |
78 |
+ return; |
79 |
+ } |
80 |
+ |
81 |
+ return \%karma_tlds; |
82 |
+} |
83 |
+ |
84 |
sub parse_db_record { |
85 |
my ($self, $value) = @_; |
86 |
|