You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by he...@apache.org on 2019/08/26 08:20:12 UTC

svn commit: r1865914 - in /spamassassin/trunk: ./ lib/Mail/SpamAssassin/ lib/Mail/SpamAssassin/Plugin/ lib/Mail/SpamAssassin/Util/ t/

Author: hege
Date: Mon Aug 26 08:20:12 2019
New Revision: 1865914

URL: http://svn.apache.org/viewvc?rev=1865914&view=rev
Log:
Use faster MaxMind::DB::Reader base module instead of the bloated GeoIP2::Database::Reader

Modified:
    spamassassin/trunk/UPGRADE
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/GeoDB.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm
    spamassassin/trunk/t/relaycountry.t
    spamassassin/trunk/t/urilocalbl.t

Modified: spamassassin/trunk/UPGRADE
URL: http://svn.apache.org/viewvc/spamassassin/trunk/UPGRADE?rev=1865914&r1=1865913&r2=1865914&view=diff
==============================================================================
--- spamassassin/trunk/UPGRADE (original)
+++ spamassassin/trunk/UPGRADE Mon Aug 26 08:20:12 2019
@@ -65,7 +65,7 @@ Note for Users Upgrading to SpamAssassin
   These enable safer and faster scanning of large emails.
 
 - New internal Mail::SpamAssassin::GeoDB module that provides unified interface to
-  modules GeoIP2::Database::Reader, Geo::IP, IP::Country::DB_File, IP::Country::Fast.
+  modules MaxMind::DB::Reader (GeoIP2), Geo::IP, IP::Country::DB_File, IP::Country::Fast.
   Utilized by RelayCountry and URILocalBL. Settings geodb_module, geodb_options,
   geodb_search_path. Deprecated settings country_db_type, country_db_path,
   uri_country_db_path, uri_country_db_isp_path still work but print a warning to

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm?rev=1865914&r1=1865913&r2=1865914&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm Mon Aug 26 08:20:12 2019
@@ -4155,7 +4155,7 @@ If not specified, all supported ones are
 
 Plugins can override this internally if required.
 
- GeoIP2::Database::Reader
+ MaxMind::DB::Reader  (same as GeoIP2::Database::Reader)
  Geo::IP
  IP::Country::DB_File  (not used unless geodb_options path set)
  IP::Country::Fast
@@ -4170,7 +4170,8 @@ Plugins can override this internally if
     code => sub {
       my ($self, $key, $value, $line) = @_;
       $value = lc $value;
-      if ($value eq 'geoip2::database::reader' || $value eq 'geoip2') {
+      if ($value eq 'maxmind::db::reader' ||
+            $value eq 'geoip2::database::reader' || $value eq 'geoip2') {
         $self->{geodb}->{module} = 'geoip2';
       } elsif ($value eq 'geo::ip' || $value eq 'geoip') {
         $self->{geodb}->{module} = 'geoip';

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/GeoDB.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/GeoDB.pm?rev=1865914&r1=1865913&r2=1865914&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/GeoDB.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/GeoDB.pm Mon Aug 26 08:20:12 2019
@@ -211,9 +211,9 @@ sub load_geoip2 {
   my ($db, $dbapi, $ok);
 
   eval {
-    require GeoIP2::Database::Reader;
+    require MaxMind::DB::Reader;
   } or do {
-    dbg("geodb: GeoIP2::Database::Reader module load failed: $@");
+    dbg("geodb: MaxMind::DB::Reader (GeoIP2) module load failed: $@");
     return (undef, undef);
   };
 
@@ -248,9 +248,8 @@ sub load_geoip2 {
 
     if (defined $path{$dbtype}) {
       eval {
-        $db->{$dbtype} = GeoIP2::Database::Reader->new(
+        $db->{$dbtype} = MaxMind::DB::Reader->new(
           file => $path{$dbtype},
-          locales => [ 'en' ]
         );
         die "unknown error" unless $db->{$dbtype};
         1;
@@ -273,19 +272,19 @@ sub load_geoip2 {
 
   # dbinfo_DBTYPE()
   $db->{city} and $dbapi->{dbinfo_city} = sub {
-    my $m = $_[0]->{db}->{city}->metadata;
+    my $m = $_[0]->{db}->{city}->metadata();
     return "GeoIP2 city: ".$m->description()->{en}." / ".localtime($m->build_epoch());
   };
   $db->{country} and $dbapi->{dbinfo_country} = sub {
-    my $m = $_[0]->{db}->{country}->metadata;
+    my $m = $_[0]->{db}->{country}->metadata();
     return "GeoIP2 country: ".$m->description()->{en}." / ".localtime($m->build_epoch());
   };
   $db->{isp} and $dbapi->{dbinfo_isp} = sub {
-    my $m = $_[0]->{db}->{isp}->metadata;
+    my $m = $_[0]->{db}->{isp}->metadata();
     return "GeoIP2 isp: ".$m->description()->{en}." / ".localtime($m->build_epoch());
   };
   $db->{asn} and $dbapi->{dbinfo_asn} = sub {
-    my $m = $_[0]->{db}->{asn}->metadata;
+    my $m = $_[0]->{db}->{asn}->metadata();
     return "GeoIP2 asn: ".$m->description()->{en}." / ".localtime($m->build_epoch());
   };
 
@@ -294,7 +293,7 @@ sub load_geoip2 {
     my $res = {};
     my $city;
     eval {
-      $city = $_[0]->{db}->{city}->city(ip=>$_[1]);
+      $city = $_[0]->{db}->{city}->record_for_address($_[1]);
       1;
     } or do {
       $@ =~ s/\s+Trace begun.*//s;
@@ -302,11 +301,11 @@ sub load_geoip2 {
       return $res;
     };
     eval {
-      $res->{city_name} = $city->{raw}->{city}->{names}->{en};
-      $res->{country} = $city->{raw}->{country}->{iso_code};
-      $res->{country_name} = $city->{raw}->{country}->{names}->{en};
-      $res->{continent} = $city->{raw}->{continent}->{code};
-      $res->{continent_name} = $city->{raw}->{continent}->{names}->{en};
+      $res->{city_name} = $city->{city}->{names}->{en};
+      $res->{country} = $city->{country}->{iso_code};
+      $res->{country_name} = $city->{country}->{names}->{en};
+      $res->{continent} = $city->{continent}->{code};
+      $res->{continent_name} = $city->{continent}->{names}->{en};
       1;
     };
     return $res;
@@ -317,7 +316,7 @@ sub load_geoip2 {
     my $res = {};
     my $country;
     eval {
-      $country = $_[0]->{db}->{country}->country(ip=>$_[1]);
+      $country = $_[0]->{db}->{country}->record_for_address($_[1]);
       1;
     } or do {
       $@ =~ s/\s+Trace begun.*//s;
@@ -325,10 +324,10 @@ sub load_geoip2 {
       return $res;
     };
     eval {
-      $res->{country} = $country->{raw}->{country}->{iso_code};
-      $res->{country_name} = $country->{raw}->{country}->{names}->{en};
-      $res->{continent} = $country->{raw}->{continent}->{code};
-      $res->{continent_name} = $country->{raw}->{continent}->{names}->{en};
+      $res->{country} = $country->{country}->{iso_code};
+      $res->{country_name} = $country->{country}->{names}->{en};
+      $res->{continent} = $country->{continent}->{code};
+      $res->{continent_name} = $country->{continent}->{names}->{en};
       1;
     };
     return $res;
@@ -339,7 +338,7 @@ sub load_geoip2 {
     my $res = {};
     my $isp;
     eval {
-      $isp = $_[0]->{db}->{isp}->isp(ip=>$_[1]);
+      $isp = $_[0]->{db}->{isp}->record_for_address($_[1]);
       1;
     } or do {
       $@ =~ s/\s+Trace begun.*//s;
@@ -347,10 +346,10 @@ sub load_geoip2 {
       return $res;
     };
     eval {
-      $res->{asn} = $isp->autonomous_system_number();
-      $res->{asn_organization} = $isp->autonomous_system_organization();
-      $res->{isp} = $isp->isp();
-      $res->{organization} = $isp->organization();
+      $res->{asn} = $isp->{autonomous_system_number};
+      $res->{asn_organization} = $isp->{autonomous_system_organization};
+      $res->{isp} = $isp->{isp};
+      $res->{organization} = $isp->{organization};
       1;
     };
     return $res;
@@ -361,7 +360,7 @@ sub load_geoip2 {
     my $res = {};
     my $asn;
     eval {
-      $asn = $_[0]->{db}->{asn}->asn(ip=>$_[1]);
+      $asn = $_[0]->{db}->{asn}->record_for_address($_[1]);
       1;
     } or do {
       $@ =~ s/\s+Trace begun.*//s;
@@ -369,8 +368,8 @@ sub load_geoip2 {
       return $res;
     };
     eval {
-      $res->{asn} = $asn->autonomous_system_number();
-      $res->{asn_organization} = $asn->autonomous_system_organization();
+      $res->{asn} = $asn->{autonomous_system_number};
+      $res->{asn_organization} = $asn->{autonomous_system_organization};
       1;
     };
     return $res;

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm?rev=1865914&r1=1865913&r2=1865914&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm Mon Aug 26 08:20:12 2019
@@ -54,7 +54,7 @@ Following metadata headers and tags are
 =head1 REQUIREMENT
 
 This plugin uses Mail::SpamAssassin::GeoDB and requires a module supported
-by it, for example GeoIP2::Database::Reader.
+by it, for example MaxMind::DB::Reader (GeoIP2).
 
 =cut
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm?rev=1865914&r1=1865913&r2=1865914&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URILocalBL.pm Mon Aug 26 08:20:12 2019
@@ -99,7 +99,7 @@ applicable to CIDR and ISP blocks as wel
 =head1 DEPENDENCIES
 
 The Country-Code based filtering can use any Mail::SpamAssassin::GeoDB
-supported module like GeoIP2::Database::Reader or Geo::IP.  ISP based
+supported module like MaxMind::DB::Reader (GeoIP2) or Geo::IP.  ISP based
 filtering might require a paid subscription database like GeoIPISP.
 
 =cut

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm?rev=1865914&r1=1865913&r2=1865914&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm Mon Aug 26 08:20:12 2019
@@ -133,7 +133,7 @@ our @OPTIONAL_MODULES = (
   address forgery and make it easier to identify spams.',
 },
 {
-  module => 'GeoIP2::Database::Reader',
+  module => 'MaxMind::DB::Reader',
   version => 0,
   desc => 'Used by the RelayCountry plugin (not enabled by default) to
   determine the domain country codes of each relay in the path of an email. 

Modified: spamassassin/trunk/t/relaycountry.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/relaycountry.t?rev=1865914&r1=1865913&r2=1865914&view=diff
==============================================================================
--- spamassassin/trunk/t/relaycountry.t (original)
+++ spamassassin/trunk/t/relaycountry.t Mon Aug 26 08:20:12 2019
@@ -16,10 +16,10 @@ use SATest; sa_t_init("relaycountry");
 
 my $tests = 0;
 my %has;
-eval { require GeoIP2::Database::Reader; $tests += 2; $has{GEOIP2}  = 1 };
-eval { require Geo::IP;                  $tests += 2; $has{GEOIP}   = 1 };
-eval { require IP::Country::DB_File;     $tests += 2; $has{DB_FILE} = 1 };
-eval { require IP::Country::Fast;        $tests += 2; $has{FAST}    = 1 };
+eval { require MaxMind::DB::Reader;   $tests += 2; $has{GEOIP2}  = 1 };
+eval { require Geo::IP;               $tests += 2; $has{GEOIP}   = 1 };
+eval { require IP::Country::DB_File;  $tests += 2; $has{DB_FILE} = 1 };
+eval { require IP::Country::Fast;     $tests += 2; $has{FAST}    = 1 };
 
 use Test::More;
 
@@ -51,7 +51,7 @@ ok_all_patterns();
 clear_pattern_counters();
 
 } else {
-  warn("skipping missing GeoIP2::Database::Reader\n");
+  warn "skipping MaxMind::DB::Reader (GeoIP2) tests (not installed)\n";
 }
 
 
@@ -78,7 +78,7 @@ ok_all_patterns();
 clear_pattern_counters();
 
 } else {
-  warn("skipping missing Geo::IP\n");
+  warn "skipping Geo::IP tests (not installed)\n";
 }
 
 
@@ -105,7 +105,7 @@ ok_all_patterns();
 clear_pattern_counters();
 
 } else {
-  warn("skipping missing IP::Country::DB_File\n");
+  warn "skipping IP::Country::DB_File tests (not installed)\n";
 }
 
 
@@ -131,6 +131,6 @@ ok_all_patterns();
 clear_pattern_counters();
 
 } else {
-  warn("skipping missing IP::Country::Fast\n");
+  warn "skipping IP::Country::Fast tests (not installed)\n";
 }
 

Modified: spamassassin/trunk/t/urilocalbl.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/urilocalbl.t?rev=1865914&r1=1865913&r2=1865914&view=diff
==============================================================================
--- spamassassin/trunk/t/urilocalbl.t (original)
+++ spamassassin/trunk/t/urilocalbl.t Mon Aug 26 08:20:12 2019
@@ -15,10 +15,10 @@ use lib '.'; use lib 't';
 use SATest; sa_t_init("urilocalbl");
 
 $tests = 0;
-eval { require GeoIP2::Database::Reader; $tests += 8; $has{GEOIP2}  = 1 };
-eval { require Geo::IP;                  $tests += 8; $has{GEOIP}   = 1 };
-eval { require IP::Country::DB_File;     $tests += 8; $has{DB_FILE} = 1 };
-eval { require IP::Country::Fast;        $tests += 8; $has{FAST}    = 1 };
+eval { require MaxMind::DB::Reader;   $tests += 8; $has{GEOIP2}  = 1 };
+eval { require Geo::IP;               $tests += 8; $has{GEOIP}   = 1 };
+eval { require IP::Country::DB_File;  $tests += 8; $has{DB_FILE} = 1 };
+eval { require IP::Country::Fast;     $tests += 8; $has{FAST}    = 1 };
 
 use Test::More;
 
@@ -111,7 +111,7 @@ if (defined $has{GEOIP2}) {
     warn "skipping DNS lookup tests (run_net_tests=n)\n";
   }
 } else {
-  warn "skipping GeoIP2::Database::Reader tests (not installed)\n";
+  warn "skipping MaxMind::DB::Reader (GeoIP2) tests (not installed)\n";
 }