2004-09-22 18:01:16 +02:00
|
|
|
# this plugin checks the relayclients config file and
|
2002-07-08 04:30:11 +02:00
|
|
|
# $ENV{RELAYCLIENT} to see if relaying is allowed.
|
|
|
|
#
|
|
|
|
|
2005-07-07 06:17:39 +02:00
|
|
|
sub hook_connect {
|
2004-09-22 18:01:16 +02:00
|
|
|
my ($self, $transaction) = @_;
|
|
|
|
my $connection = $self->qp->connection;
|
2003-01-20 12:03:15 +01:00
|
|
|
|
2003-11-02 12:14:44 +01:00
|
|
|
# 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) {
|
2004-06-16 22:28:57 +02:00
|
|
|
if (exists($ENV{RELAYCLIENT}) or
|
|
|
|
exists($relay_clients{$client_ip}) or
|
|
|
|
exists($more_relay_clients->{$client_ip}))
|
|
|
|
{
|
2004-09-22 18:01:16 +02:00
|
|
|
$connection->relay_client(1);
|
|
|
|
last;
|
2004-06-16 22:28:57 +02:00
|
|
|
}
|
2006-08-28 01:17:33 +02:00
|
|
|
$client_ip =~ s/(\d|\w|::)+(:|\.)?$//; # strip off another 8 bits
|
2003-11-02 12:14:44 +01:00
|
|
|
}
|
|
|
|
|
2004-09-22 18:01:16 +02:00
|
|
|
return (DECLINED);
|
2002-07-08 04:30:11 +02:00
|
|
|
}
|