87 lines
2.7 KiB
Diff
87 lines
2.7 KiB
Diff
diff -Nur -x '*.orig' -x '*.rej' qpsmtpd-0.96/config.sample/karma_tlds mezzanine_patched_qpsmtpd-0.96/config.sample/karma_tlds
|
|
--- qpsmtpd-0.96/config.sample/karma_tlds 1970-01-01 01:00:00.000000000 +0100
|
|
+++ mezzanine_patched_qpsmtpd-0.96/config.sample/karma_tlds 2016-04-20 20:44:35.881444632 +0200
|
|
@@ -0,0 +1,14 @@
|
|
+# Karma to apply depending on the tld of the envelope sender
|
|
+# Used by the karma plugin
|
|
+# Warning: setting karma too low can blacklist the entire tld
|
|
+work:-4
|
|
+rocks:-3
|
|
+ninja:-3
|
|
+info:-2
|
|
+biz:-2
|
|
+pw:-2
|
|
+me:-1
|
|
+us:-5
|
|
+eu:-4
|
|
+link:-3
|
|
+science:-6
|
|
diff -Nur -x '*.orig' -x '*.rej' qpsmtpd-0.96/plugins/karma mezzanine_patched_qpsmtpd-0.96/plugins/karma
|
|
--- qpsmtpd-0.96/plugins/karma 2016-04-20 20:44:38.326444593 +0200
|
|
+++ mezzanine_patched_qpsmtpd-0.96/plugins/karma 2016-04-20 19:18:31.922041433 +0200
|
|
@@ -102,6 +102,20 @@
|
|
|
|
Adjust the quantity of logging for this plugin. See docs/logging.pod
|
|
|
|
+=head1 CONFIG FILES
|
|
+
|
|
+This plugin uses the following configuration files. All are optional.
|
|
+
|
|
+=head2 karma_tlds
|
|
+
|
|
+This file can contain semicolon separated tld and the corresponding
|
|
+karma adjustment to apply when the envelope sender match. It can be used to
|
|
+penalize "spammy" tlds, or to raise the karma from (mostly) good tlds.
|
|
+
|
|
+jp:-4
|
|
+ch:-3
|
|
+fr:+1
|
|
+
|
|
=head1 BENEFITS
|
|
|
|
Karma reduces the resources wasted by naughty mailers. When used with
|
|
@@ -352,18 +366,14 @@
|
|
my $full_from = $self->connection->notes('envelope_from');
|
|
$self->illegal_envelope_format( $full_from );
|
|
|
|
- my %spammy_tlds = (
|
|
- map { $_ => 4 } qw/ info pw /,
|
|
- map { $_ => 3 } qw/ tw biz /,
|
|
- map { $_ => 2 } qw/ cl br fr be jp no se sg /,
|
|
- );
|
|
- foreach my $tld ( keys %spammy_tlds ) {
|
|
+ my $karma_tlds = $self->get_karma_tlds() or return DECLINED;
|
|
+ foreach my $tld ( keys %$karma_tlds ) {
|
|
my $len = length $tld;
|
|
- my $score = $spammy_tlds{$tld} or next;
|
|
+ my $score = $karma_tlds->{$tld} or next;
|
|
$len ++;
|
|
if ( $sender->host && ".$tld" eq substr($sender->host,-$len,$len) ) {
|
|
- $self->log(LOGINFO, "penalizing .$tld envelope sender");
|
|
- $self->adjust_karma(-$score);
|
|
+ $self->log(LOGINFO, "adjusting karma for .$tld envelope sender");
|
|
+ $self->adjust_karma($score);
|
|
}
|
|
}
|
|
|
|
@@ -479,6 +489,19 @@
|
|
}
|
|
}
|
|
|
|
+sub get_karma_tlds {
|
|
+ my $self = shift;
|
|
+
|
|
+ my %karma_tlds =
|
|
+ map { (split /:/, $_, 2)[0, 1] } $self->qp->config('karma_tlds');
|
|
+ if (!%karma_tlds) {
|
|
+ $self->log(LOGDEBUG, "no specific karma for tlds defined");
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ return \%karma_tlds;
|
|
+}
|
|
+
|
|
sub parse_db_record {
|
|
my ($self, $value) = @_;
|
|
|