[2/2] firewall-lib.pl: Use get_geoip_locations fromgeoip-functions.pl

Message ID 20190110194004.3341-2-stefan.schantl@ipfire.org
State Accepted
Commit 8ff42d82c4ab2d5743b1fdcd076249c7b2e51794
Headers
Series [1/2] geoip-locations.pl: Add get_geoip_locations(). |

Commit Message

Stefan Schantl Jan. 11, 2019, 6:40 a.m. UTC
  Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 config/firewall/firewall-lib.pl | 32 ++------------------------------
 1 file changed, 2 insertions(+), 30 deletions(-)
  

Patch

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;