qpsmtpd/plugins/ident/geoip
Robert Spier 90daeb3786 r483@dog: rspier | 2005-07-06 21:17:00 -0700
The great plugin renaming in the name of inheritance and standardization commit.
 
 1. new concept of standard hook_ names.
 2. Plugin::init
 3. renamed many subroutines in plugins (and cleaned up register subs)
 4. updated README.plugins
 


git-svn-id: https://svn.perl.org/qpsmtpd/trunk@479 958fd67b-6ff1-0310-b445-bb7760255be9
2005-07-07 04:17:39 +00:00

31 lines
663 B
Perl

# -*- 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;
my $geoip = Geo::IP->new(GEOIP_STANDARD);
sub hook_connect {
my ($self) = @_;
my $country =
$geoip->country_code_by_addr( $self->qp->connection->remote_ip );
$self->qp->connection->notes('geoip_country', $country);
$self->log(LOGNOTICE, "GeoIP Country: $country");
return DECLINED;
}