From 8de22de762df113906b757aacc74ca2a65a2f9bd Mon Sep 17 00:00:00 2001 From: Jared Johnson Date: Mon, 15 Dec 2014 13:56:56 -0600 Subject: [PATCH 1/2] Try to load geoip1 before geoip2 --- plugins/ident/geoip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ident/geoip b/plugins/ident/geoip index 876be84..e67cd85 100644 --- a/plugins/ident/geoip +++ b/plugins/ident/geoip @@ -146,8 +146,8 @@ sub register { sub load_geoip { my ( $self ) = @_; - $self->load_geoip2() and return 1; $self->load_geoip1() and return 1; + $self->load_geoip2() and return 1; return 0; } From ea937f89dc6380d924ac86e4f09677bb67e231f6 Mon Sep 17 00:00:00 2001 From: Jared Johnson Date: Mon, 15 Dec 2014 17:33:11 -0600 Subject: [PATCH 2/2] Warn about lack of ASN data when GeoIP2 is loaded --- plugins/ident/geoip | 8 +++++++- t/plugin_tests/ident/geoip | 3 --- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/ident/geoip b/plugins/ident/geoip index e67cd85..53e81fe 100644 --- a/plugins/ident/geoip +++ b/plugins/ident/geoip @@ -182,7 +182,8 @@ sub load_geoip2 { return; } - $self->log(LOGINFO, "GeoIP2 loaded"); + warn "Using GeoIP2." + . " ASN data is not currently available using the GeoIP2 module!\n"; eval { $self->{_geoip2_city} = GeoIP2::Database::Reader->new( @@ -308,22 +309,27 @@ sub open_geoip_db { next if !-f "$db_dir/$db.dat"; $self->log(LOGINFO, "using db $db"); $self->{_geoip_city} = Geo::IP->open("$db_dir/$db.dat"); + last if $self->{_geoip_city}; } + warn "Missing GeoIP City data!\n" if ! $self->{_geoip_city}; if (-f "$db_dir/GeoIPASNum.dat") { $self->log(LOGINFO, "using GeoIPASNum"); $self->{GeoIPASNum} = Geo::IP->open("$db_dir/GeoIPASNum.dat"); } + warn "Missing GeoIP ASN data!\n" if ! $self->{GeoIPASNum}; if (-f "$db_dir/GeoIPASNumv6.dat") { $self->log(LOGINFO, "using GeoIPASNumv6"); $self->{GeoIPASNumv6} = Geo::IP->open("$db_dir/GeoIPASNumv6.dat"); + warn "Missing GeoIP ASN IPV6 data!\n" if ! $self->{GeoIPASNum}; } # can't think of a good reason to load country if city data is present if (!$self->{_geoip_city}) { $self->log(LOGDEBUG, "using default db"); $self->{_geoip} = Geo::IP->new(); # loads default Country DB + warn "Missing GeoIP Country data!\n" if ! $self->{_geoip}; } } diff --git a/t/plugin_tests/ident/geoip b/t/plugin_tests/ident/geoip index d830627..d28ed10 100644 --- a/t/plugin_tests/ident/geoip +++ b/t/plugin_tests/ident/geoip @@ -11,14 +11,11 @@ sub register_tests { eval 'use GeoIP2::Database::Reader'; if ( !$@ ) { - warn "using GeoIP2\n"; $self->register_test('test_geoip2_lookup'); } eval 'use Geo::IP'; if ( !$@ ) { - warn "loaded Geo::IP\n"; - $self->register_test('test_geoip_lookup'); $self->register_test('test_geoip_load_db'); $self->register_test('test_geoip_init_cc');