f92e99bd9c
* plugins/rcpt_ok Split check_relay into two plugins * config/plugins Reorder plugins to take advantage of the new check_relay * lib/Qpsmtpd/Connection.pm Add support for relay_client() method * lib/Qpsmtpd/SMTP.pm Copy connection relay settings to transaction object when created * lib/Qpsmtpd/Auth.pm Use the connection->relay_client() instead of setting an env var git-svn-id: https://svn.perl.org/qpsmtpd/trunk@326 958fd67b-6ff1-0310-b445-bb7760255be9
32 lines
876 B
Plaintext
32 lines
876 B
Plaintext
# this plugin checks the relayclients config file and
|
|
# $ENV{RELAYCLIENT} to see if relaying is allowed.
|
|
#
|
|
|
|
sub register {
|
|
my ($self, $qp) = @_;
|
|
$self->register_hook("connect", "check_relay");
|
|
}
|
|
|
|
sub check_relay {
|
|
my ($self, $transaction) = @_;
|
|
my $connection = $self->qp->connection;
|
|
|
|
# Check if this IP is allowed to relay
|
|
my @relay_clients = $self->qp->config("relayclients");
|
|
my $more_relay_clients = $self->qp->config("morerelayclients", "map");
|
|
my %relay_clients = map { $_ => 1 } @relay_clients;
|
|
my $client_ip = $self->qp->connection->remote_ip;
|
|
while ($client_ip) {
|
|
if (exists($ENV{RELAYCLIENT}) or
|
|
exists($relay_clients{$client_ip}) or
|
|
exists($more_relay_clients->{$client_ip}))
|
|
{
|
|
$connection->relay_client(1);
|
|
last;
|
|
}
|
|
$client_ip =~ s/\d+\.?$//; # strip off another 8 bits
|
|
}
|
|
|
|
return (DECLINED);
|
|
}
|