move 'use ParaDNS' into register and eval it

so eventually, plugin tests can run against it, if ParaDNS can be loaded
This commit is contained in:
Matt Simerson 2012-05-23 16:13:00 -04:00
parent 2f49cafcd6
commit e8e47ad93b

View File

@ -1,10 +1,15 @@
#!perl -w #!perl -w
use strict;
use warnings;
use Qpsmtpd::Constants;
use Qpsmtpd::DSN; use Qpsmtpd::DSN;
use ParaDNS;
use Socket;
use Qpsmtpd::TcpServer; use Qpsmtpd::TcpServer;
#use ParaDNS; # moved into register
use Socket;
my %invalid = (); my %invalid = ();
my $has_ipv6 = Qpsmtpd::TcpServer::has_ipv6(); my $has_ipv6 = Qpsmtpd::TcpServer::has_ipv6();
@ -19,6 +24,11 @@ sub register {
} }
} }
eval 'use ParaDNS';
if ( $@ ) {
warn "could not load ParaDNS, plugin disabled";
return DECLINED;
};
$self->register_hook( mail => 'hook_mail_start' ); $self->register_hook( mail => 'hook_mail_start' );
$self->register_hook( mail => 'hook_mail_done' ); $self->register_hook( mail => 'hook_mail_done' );
} }
@ -26,11 +36,10 @@ sub register {
sub hook_mail_start { sub hook_mail_start {
my ( $self, $transaction, $sender ) = @_; my ( $self, $transaction, $sender ) = @_;
return DECLINED return DECLINED if $self->qp->connection->notes('whitelisthost');
if ( $self->qp->connection->notes('whitelisthost') );
if ( $sender ne '<>' ) {
if ( $sender ne "<>" ) {
unless ( $sender->host ) { unless ( $sender->host ) {
# default of addr_bad_from_system is DENY, we use DENYSOFT here to # default of addr_bad_from_system is DENY, we use DENYSOFT here to
# get the same behaviour as without Qpsmtpd::DSN... # get the same behaviour as without Qpsmtpd::DSN...
@ -47,7 +56,7 @@ sub hook_mail_start {
return YIELD; return YIELD;
} }
return DECLINED; return DECLINED;
} }