[Mimedefang] DNSWL

Tilman Schmidt t.schmidt at phoenixsoftware.de
Tue Oct 30 12:59:53 EDT 2012


Am 30.10.2012 15:59, schrieb David F. Skoll:
> First of all, from the mimedefang-filter man page:
> 
>        Note that the "relay_is_blacklisted" functions are deprecated
>        and may be removed in a future release.  Instead, you should
>        use the module Net::DNSBL::Client from CPAN.

Thanks. Given that relay_is_blacklisted_multi appears to fall
under the "deprectated" verdict as well, and despite previous
bad experience with using CPAN on an RPM based Linux distribution,
I gave the Net::DNSBL::Client module a try. This is what I came up
with:

    # Spam checks if SpamAssassin is installed
    if ($Features{"SpamAssassin"}) {
        if ($RelayAddr =~ /^10\.0\./) {
            # Don't scan messages from local net
            md_graphdefang_log('locl');
        }
        elsif (defined($SendmailMacros{"auth_type"})) {
            # Don't scan messages from authenticated senders.
            md_graphdefang_log('auth');
        }
        elsif (-s "./INPUTMSG" < 100*1024) {
            # Only scan messages smaller than 100kB.

          use Net::DNSBL::Client;
          my $c = Net::DNSBL::Client->new({ timeout => 3 });
          $c->query_ip($RelayAddr,
                        [ { domain => 'list.dnswl.org',
                            type => 'mask', data => '0.0.0.254' } ]);
          my $answers = $c->get_answers();
          if (@$answers) {
            md_graphdefang_log('dnswl');
          }
          else {
            my($hits, $req, $names, $report) = spam_assassin_check();
            if ($hits >= $req) {
                ...yadda...
            }
          }
        }
    }

Does that look about right? It seems to work fine so far, anyway.
Pity I couldn't avoid the extra level of braces, though.

-- 
Tilman Schmidt
Phoenix Software GmbH
Bonn, Germany



More information about the MIMEDefang mailing list