smeserver-qpsmtpd/root/etc/e-smith/db/configuration/migrate/20SBLLIST

39 lines
1.2 KiB
Plaintext
Raw Normal View History

{
$qpsmtpd = $DB->get('qpsmtpd');
return unless $qpsmtpd;
my $sbl = $qpsmtpd->prop('SBLList');
return unless $sbl;
my @sbl = ();
# Migrate to use , as separator instead of :
if ($sbl !~ m/,/){
my @zones = split /[:]/, $sbl;
my $fqdn_re = qr/([a-zA-Z0-9][a-zA-Z0-9\-]{1,61}\.)*[a-zA-Z0-9][a-zA-Z0-9\-]{1,61}\.[a-zA-Z]{2,}/;
if (scalar @zones == 2 && $zones[1] !~ m/^$fqdn_re$/){
# When we have only two entries, check if the second one looks like a valid hostname
# so if you only have something like rhsbl.foo.net:Sorry you are blacklisted
# it won't be migrated to rhsbl.foo.net,Sorry you are blacklisted
@sbl = ($sbl);
}
else{
@sbl = @zones;
}
}
else{
@sbl = split /[,]/, $sbl;
}
my %obsolete = map { $_ => 1} qw(
blackhole.securitysage.com
bulk.rhs.mailpolice.com
fraud.rhs.mailpolice.com
porn.rhs.mailpolice.com
adult.rhs.mailpolice.com
bogusmx.rfc-ignorant.org
ex.dnsbl.org
);
@sbl = grep { !$obsolete{$_} } @sbl;
$qpsmtpd->set_prop('SBLList', join ',', @sbl);
}