Skip to content

Commit

Permalink
Merge pull request #21 from msimerson/fromhost
Browse files Browse the repository at this point in the history
resolvable_fromhost refactor, adding tests
  • Loading branch information
abh committed Jun 4, 2012
2 parents 9e239fd + e8e47ad commit bfa7324
Show file tree
Hide file tree
Showing 3 changed files with 468 additions and 126 deletions.
23 changes: 16 additions & 7 deletions plugins/async/require_resolvable_fromhost
@@ -1,10 +1,15 @@
#!perl -w

use strict;
use warnings;

use Qpsmtpd::Constants;
use Qpsmtpd::DSN;
use ParaDNS;
use Socket;
use Qpsmtpd::TcpServer;

#use ParaDNS; # moved into register
use Socket;

my %invalid = ();
my $has_ipv6 = Qpsmtpd::TcpServer::has_ipv6();

Expand All @@ -19,18 +24,22 @@ 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_done' );
}

sub hook_mail_start {
my ( $self, $transaction, $sender ) = @_;

return DECLINED
if ( $self->qp->connection->notes('whitelisthost') );
return DECLINED if $self->qp->connection->notes('whitelisthost');

if ( $sender ne '<>' ) {

if ( $sender ne "<>" ) {

unless ( $sender->host ) {
# default of addr_bad_from_system is DENY, we use DENYSOFT here to
# get the same behaviour as without Qpsmtpd::DSN...
Expand All @@ -47,7 +56,7 @@ sub hook_mail_start {

return YIELD;
}

return DECLINED;
}

Expand Down

0 comments on commit bfa7324

Please sign in to comment.