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 2018/09/19 20:07:27 UTC
svn commit: r1841378 - in /spamassassin:
branches/3.4/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm
trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm
Author: hege
Date: Wed Sep 19 20:07:27 2018
New Revision: 1841378
URL: http://svn.apache.org/viewvc?rev=1841378&view=rev
Log:
Try default database locations for GeoIP2
Modified:
spamassassin/branches/3.4/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm
Modified: spamassassin/branches/3.4/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.4/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm?rev=1841378&r1=1841377&r2=1841378&view=diff
==============================================================================
--- spamassassin/branches/3.4/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm (original)
+++ spamassassin/branches/3.4/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm Wed Sep 19 20:07:27 2018
@@ -110,6 +110,12 @@ Valid database types are GeoIP, GeoIP2,
This option tells SpamAssassin where to find MaxMind GeoIP2 or IP::Country::DB_File database.
+If not defined, GeoIP2 default search includes:
+ /usr/local/share/GeoIP/GeoIP2-Country.mmdb
+ /usr/share/GeoIP/GeoIP2-Country.mmdb
+ /usr/local/share/GeoIP/GeoLite2-Country.mmdb
+ /usr/share/GeoIP/GeoLite2-Country.mmdb
+
=back
=cut
@@ -164,6 +170,18 @@ sub extract_metadata {
}
}
elsif ($conf_country_db_type eq "GeoIP2") {
+ if (!$conf_country_db_path) {
+ # Try some default locations
+ foreach (("/usr/local/share/GeoIP/GeoIP2-Country.mmdb",
+ "/usr/share/GeoIP/GeoIP2-Country.mmdb",
+ "/usr/local/share/GeoIP/GeoLite2-Country.mmdb",
+ "/usr/share/GeoIP/GeoLite2-Country.mmdb")) {
+ if (-f $_) {
+ $conf_country_db_path = $_;
+ last;
+ }
+ }
+ }
if (-f $conf_country_db_path) {
eval {
require GeoIP2::Database::Reader;
@@ -185,7 +203,9 @@ sub extract_metadata {
}
} else {
# Fallback to IP::Country::Fast
- dbg("metadata: RelayCountry: GeoIP2: ${conf_country_db_path} not found, trying IP::Country::Fast as fallback");
+ my $err = $conf_country_db_path ?
+ "$conf_country_db_path not found" : "database not found from default locations";
+ dbg("metadata: RelayCountry: GeoIP2: $err, trying IP::Country::Fast as fallback");
$conf_country_db_type = "Fast";
}
}
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm?rev=1841378&r1=1841377&r2=1841378&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm Wed Sep 19 20:07:27 2018
@@ -110,6 +110,12 @@ Valid database types are GeoIP, GeoIP2,
This option tells SpamAssassin where to find MaxMind GeoIP2 or IP::Country::DB_File database.
+If not defined, GeoIP2 default search includes:
+ /usr/local/share/GeoIP/GeoIP2-Country.mmdb
+ /usr/share/GeoIP/GeoIP2-Country.mmdb
+ /usr/local/share/GeoIP/GeoLite2-Country.mmdb
+ /usr/share/GeoIP/GeoLite2-Country.mmdb
+
=back
=cut
@@ -164,6 +170,18 @@ sub extract_metadata {
}
}
elsif ($conf_country_db_type eq "GeoIP2") {
+ if (!$conf_country_db_path) {
+ # Try some default locations
+ foreach (("/usr/local/share/GeoIP/GeoIP2-Country.mmdb",
+ "/usr/share/GeoIP/GeoIP2-Country.mmdb",
+ "/usr/local/share/GeoIP/GeoLite2-Country.mmdb",
+ "/usr/share/GeoIP/GeoLite2-Country.mmdb")) {
+ if (-f $_) {
+ $conf_country_db_path = $_;
+ last;
+ }
+ }
+ }
if (-f $conf_country_db_path) {
eval {
require GeoIP2::Database::Reader;
@@ -185,7 +203,9 @@ sub extract_metadata {
}
} else {
# Fallback to IP::Country::Fast
- dbg("metadata: RelayCountry: GeoIP2: ${conf_country_db_path} not found, trying IP::Country::Fast as fallback");
+ my $err = $conf_country_db_path ?
+ "$conf_country_db_path not found" : "database not found from default locations";
+ dbg("metadata: RelayCountry: GeoIP2: $err, trying IP::Country::Fast as fallback");
$conf_country_db_type = "Fast";
}
}