a23d4b3da9
Exclude some tests with dependencies. Remove -T from perl line in plugins This makes it harder to test with PERL5LIB/perlbrew etc
31 lines
718 B
Perl
31 lines
718 B
Perl
#!perl -w
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
This plugin uses MaxMind's GeoIP service and the Geo::IP perl module to
|
|
do a lookup on incoming connections and record the country of origin.
|
|
|
|
Thats all it does.
|
|
|
|
It logs the country to the connection notes 'geoip_country'. Another
|
|
plugin can use that value to do things to the connection, like reject,
|
|
or greylist.
|
|
|
|
=cut
|
|
|
|
use Geo::IP;
|
|
|
|
sub hook_connect {
|
|
my ($self) = @_;
|
|
|
|
my $geoip = Geo::IP->new(GEOIP_STANDARD);
|
|
my $country =
|
|
$geoip->country_code_by_addr( $self->qp->connection->remote_ip )
|
|
or return (DECLINED);
|
|
|
|
$self->qp->connection->notes('geoip_country', $country);
|
|
$self->log(LOGNOTICE, "GeoIP Country: $country");
|
|
|
|
return DECLINED;
|
|
}
|