summaryrefslogtreecommitdiff
path: root/lib/DAKKAR/Graylister.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/DAKKAR/Graylister.pm')
-rw-r--r--lib/DAKKAR/Graylister.pm85
1 files changed, 3 insertions, 82 deletions
diff --git a/lib/DAKKAR/Graylister.pm b/lib/DAKKAR/Graylister.pm
index 9ee9be0..bd07e6d 100644
--- a/lib/DAKKAR/Graylister.pm
+++ b/lib/DAKKAR/Graylister.pm
@@ -1,88 +1,9 @@
package DAKKAR::Graylister;
use strict;
use warnings;
-use Net::DNSBLLookup;
+use DAKKAR::Net::DNSBLLookup;
use DBI;
-{
- %Net::DNSBLLookup::dns_servers=(
- 'dnsbl.sorbs.net' => {
- '127.0.0.2' => Net::DNSBLLookup::DNSBLLOOKUP_OPEN_PROXY_HTTP,
- '127.0.0.3' => Net::DNSBLLookup::DNSBLLOOKUP_OPEN_PROXY_SOCKS,
- '127.0.0.4' => Net::DNSBLLookup::DNSBLLOOKUP_OPEN_PROXY_MISC,
- '127.0.0.5' => Net::DNSBLLookup::DNSBLLOOKUP_OPEN_RELAY,
- '127.0.0.6' => Net::DNSBLLookup::DNSBLLOOKUP_SPAMHOUSE,
- '127.0.0.7' => Net::DNSBLLookup::DNSBLLOOKUP_FORMMAIL,
- '127.0.0.8' => Net::DNSBLLookup::DNSBLLOOKUP_CONFIRMED_SPAM,
- '127.0.0.9' => Net::DNSBLLookup::DNSBLLOOKUP_HIJACKED,
- '127.0.0.10' => Net::DNSBLLookup::DNSBLLOOKUP_DYNAMIC_IP,
- },
- 'dnsbl.njabl.org' => {
- '127.0.0.2' => Net::DNSBLLookup::DNSBLLOOKUP_OPEN_RELAY,
- '127.0.0.3' => Net::DNSBLLookup::DNSBLLOOKUP_DYNAMIC_IP,
- '127.0.0.4' => Net::DNSBLLookup::DNSBLLOOKUP_SPAMHOUSE,
- '127.0.0.5' => Net::DNSBLLookup::DNSBLLOOKUP_MULTI_OPEN_RELAY,
- '127.0.0.8' => Net::DNSBLLookup::DNSBLLOOKUP_FORMMAIL,
- '127.0.0.9' => Net::DNSBLLookup::DNSBLLOOKUP_OPEN_PROXY,
- },
- 'bl.spamcop.net' => {
- '127.0.0.2' => Net::DNSBLLookup::DNSBLLOOKUP_UNKNOWN,
- },
- 'unconfirmed.dsbl.org' => {
- '127.0.0.2' => Net::DNSBLLookup::DNSBLLOOKUP_UNKNOWN,
- },
- 'list.dsbl.org' => {
- '127.0.0.2' => Net::DNSBLLookup::DNSBLLOOKUP_UNKNOWN,
- },
- 'sbl.spamhaus.org' => {
- '127.0.0.2' => Net::DNSBLLookup::DNSBLLOOKUP_SPAMHOUSE,
- },
- 'pbl.spamhaus.org' => {
- '127.0.0.10' => Net::DNSBLLookup::DNSBLLOOKUP_DYNAMIC_IP,
- '127.0.0.11' => Net::DNSBLLookup::DNSBLLOOKUP_DYNAMIC_IP,
- },
- 'cbl.abuseat.org' => {
- '127.0.0.2' => Net::DNSBLLookup::DNSBLLOOKUP_OPEN_PROXY,
- },
- 'psbl.surriel.com' => {
- '127.0.0.2' => Net::DNSBLLookup::DNSBLLOOKUP_OPEN_PROXY,
- },
- );
-
- use Net::DNSBLLookup::Result;
- {package Net::DNSBLLookup::Result;
- our %result_type;
- no warnings 'redefine';
- sub breakdown {
- my ($self)=@_;
- my ($total_spam, $total_proxy, $total_unknown, $total_dyn) = (0,0,0);
- return unless exists $self->{results};
- while (my ($dnsbl, $v) = each %{$self->{results}}) {
- my ($is_spam, $is_proxy, $is_unknown, $is_dyn) = (0,0,0,0);
- for my $retval (@$v) {
- my $result_type = $result_type{$retval};
- if ($result_type == DNSBLLOOKUP_RESULT_OPEN_PROXY) {
- $is_proxy = 1;
- } elsif ($result_type == DNSBLLOOKUP_RESULT_SPAM) {
- $is_spam = 1;
- } elsif ($result_type == DNSBLLOOKUP_RESULT_UNKNOWN) {
- $is_unknown = 1;
- } elsif ($result_type == DNSBLLOOKUP_RESULT_DYNAMIC_IP) {
- $is_dyn = 1;
- }
- }
- $total_proxy += $is_proxy;
- $total_spam += $is_spam;
- $total_dyn += $is_dyn;
- unless ($is_proxy || $is_spam || $is_dyn) {
- $total_unknown += $is_unknown;
- }
- }
- return ($total_proxy, $total_spam, $total_dyn, $total_unknown);
- }
-}
-}
-
my $DBNAME;
sub get_from_env {
@@ -191,7 +112,7 @@ sub check {
{},time(),$host,$from,$to);
}
else {
- # prbobaly a bounce
+ # probably a bounce
my $ret=$dbh->do('DELETE FROM attempts WHERE host=? AND smtpfrom=? AND smtprcpt=?',
{},$host,$from,$to);
}
@@ -207,7 +128,7 @@ sub check {
sub is_blacklisted {
my ($host)=@_;
- my $look=Net::DNSBLLookup->new();
+ my $look=DAKKAR::Net::DNSBLLookup->new();
my $ret=$look->lookup($host);
my ($proxy, $spam, $dyn, $unknown) = $ret->breakdown;
return ($proxy+$spam+$dyn+$unknown > 0);