2004-08-29 09:47:25 +02:00
|
|
|
# -*- perl -*-
|
|
|
|
|
|
|
|
=pod
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2005-07-07 06:17:39 +02:00
|
|
|
sub hook_connect {
|
2012-04-22 23:00:53 +02:00
|
|
|
my ($self) = @_;
|
2004-08-29 09:47:25 +02:00
|
|
|
|
2012-04-22 23:00:53 +02:00
|
|
|
my $geoip = Geo::IP->new(GEOIP_STANDARD);
|
|
|
|
my $country =
|
|
|
|
$geoip->country_code_by_addr( $self->qp->connection->remote_ip )
|
|
|
|
or return (DECLINED);
|
2004-08-29 09:47:25 +02:00
|
|
|
|
2012-04-22 23:00:53 +02:00
|
|
|
$self->qp->connection->notes('geoip_country', $country);
|
|
|
|
$self->log(LOGNOTICE, "GeoIP Country: $country");
|
2004-08-29 09:47:25 +02:00
|
|
|
|
2012-04-22 23:00:53 +02:00
|
|
|
return DECLINED;
|
2004-08-29 09:47:25 +02:00
|
|
|
}
|