This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "IPFire 2.x development tree".
The branch, next has been updated
via a04ec923897debb91c72b4c6223586ca0f1c7486 (commit)
via 8ff42d82c4ab2d5743b1fdcd076249c7b2e51794 (commit)
via 30c59cbb0b370a0fd1470087a94d91b35d4e54a3 (commit)
from e3429b4aad01ad011792d00570a3190d0058e7ff (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a04ec923897debb91c72b4c6223586ca0f1c7486
Author: Michael Tremer <michael.tremer(a)ipfire.org>
Date: Thu Jan 10 22:43:45 2019 +0000
core127: Ship updated firewall functions library
Signed-off-by: Michael Tremer <michael.tremer(a)ipfire.org>
commit 8ff42d82c4ab2d5743b1fdcd076249c7b2e51794
Author: Stefan Schantl <stefan.schantl(a)ipfire.org>
Date: Thu Jan 10 20:40:04 2019 +0100
firewall-lib.pl: Use get_geoip_locations from geoip-functions.pl
Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer(a)ipfire.org>
commit 30c59cbb0b370a0fd1470087a94d91b35d4e54a3
Author: Stefan Schantl <stefan.schantl(a)ipfire.org>
Date: Thu Jan 10 20:40:03 2019 +0100
geoip-locations.pl: Add get_geoip_locations().
This function is used to get all available GeoIP locations.
The functions returns them as array, sorted in alphabetical order.
Reference #11959
Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer(a)ipfire.org>
-----------------------------------------------------------------------
Summary of changes:
config/cfgroot/geoip-functions.pl | 33 +++++++++++++++++++++++++++++++
config/firewall/firewall-lib.pl | 32 ++----------------------------
config/rootfiles/core/127/filelists/files | 1 +
3 files changed, 36 insertions(+), 30 deletions(-)
Difference in files:
diff --git a/config/cfgroot/geoip-functions.pl b/config/cfgroot/geoip-functions.pl
index e8ce8377f..9f86a09ba 100644
--- a/config/cfgroot/geoip-functions.pl
+++ b/config/cfgroot/geoip-functions.pl
@@ -178,4 +178,37 @@ sub get_full_country_name($) {
return $name;
}
+# Function to get all available GeoIP locations.
+sub get_geoip_locations() {
+ my @locations;
+
+ # Open the location database.
+ open(LOCATION, "$geoip_database_dir/$location_database") or die "Could not open $geoip_database_dir/$location_database. $!\n";
+
+ # Loop through the file.
+ while(my $line = <LOCATION>) {
+ # Remove newlines.
+ chomp($line);
+
+ # Split the line content.
+ my ($geoname_id, $locale_code, $continent_code, $continent_name, $country_iso_code, $country_name, $is_in_european_union) = split(/\,/, $line);
+
+ # Check if the country_iso_code is upper case.
+ if($country_iso_code =~ /[A-Z]/) {
+ # Add the current ISO code.
+ push(@locations, $country_iso_code);
+ }
+ }
+
+ # Close filehandle.
+ close(LOCATION);
+
+ # Sort locations array in alphabetical order.
+ my @sorted_locations = sort(@locations);
+
+ # Return the array..
+ return @sorted_locations;
+}
+
+
1;
diff --git a/config/firewall/firewall-lib.pl b/config/firewall/firewall-lib.pl
index 9b7f55c9d..c14023e7b 100644
--- a/config/firewall/firewall-lib.pl
+++ b/config/firewall/firewall-lib.pl
@@ -39,6 +39,7 @@ my %ovpnsettings=();
my %aliases=();
require '/var/ipfire/general-functions.pl';
+require '${General::swroot}/geoip-locations.pl';
my $confignet = "${General::swroot}/fwhosts/customnetworks";
my $confighost = "${General::swroot}/fwhosts/customhosts";
@@ -591,36 +592,7 @@ sub get_internal_firewall_ip_address
}
sub get_geoip_locations() {
- # Path to the directory which contains the binary geoip
- # databases.
- my $directory="/usr/share/xt_geoip/LE";
-
- # Array to store the final country list.
- my @country_codes = ();
-
- # Open location and do a directory listing.
- opendir(DIR, "$directory");
- my @locations = readdir(DIR);
- closedir(DIR);
-
- # Loop through the directory listing, and cut of the file extensions.
- foreach my $location (sort @locations) {
- # skip . and ..
- next if($location =~ /^\.$/);
- next if($location =~ /^\.\.$/);
-
- # Remove whitespaces.
- chomp($location);
-
- # Cut-off file extension.
- my ($country_code, $extension) = split(/\./, $location);
-
- # Add country code to array.
- push(@country_codes, $country_code);
- }
-
- # Return final array.
- return @country_codes;
+ return &GeoIP::get_geoip_locations();
}
return 1;
diff --git a/config/rootfiles/core/127/filelists/files b/config/rootfiles/core/127/filelists/files
index 6126e32e1..4b001af63 100644
--- a/config/rootfiles/core/127/filelists/files
+++ b/config/rootfiles/core/127/filelists/files
@@ -15,5 +15,6 @@ srv/web/ipfire/cgi-bin/ids.cgi
srv/web/ipfire/cgi-bin/ovpnmain.cgi
srv/web/ipfire/cgi-bin/proxy.cgi
srv/web/ipfire/cgi-bin/vpnmain.cgi
+usr/lib/firewall/firewall-lib.pl
var/ipfire/backup/include
var/ipfire/geoip-functions.pl
hooks/post-receive
--
IPFire 2.x development tree