From: Stefan Schantl Date: Wed, 10 Jun 2020 19:27:06 +0000 (+0200) Subject: Revert "geoip-functions.pl: Add functions to export locations and to flush them." X-Git-Tag: v2.25-core148~64 X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=commitdiff_plain;h=e7b1b002c90ef52f25027a55399bb25d0f3ec55a Revert "geoip-functions.pl: Add functions to export locations and to flush them." This reverts commit e758c7638491eee86720a6b9be097124cbeb9d80. Signed-off-by: Stefan Schantl --- diff --git a/config/cfgroot/geoip-functions.pl b/config/cfgroot/geoip-functions.pl index 885c841dbf..d516ae89cd 100644 --- a/config/cfgroot/geoip-functions.pl +++ b/config/cfgroot/geoip-functions.pl @@ -198,63 +198,4 @@ sub get_geoip_locations() { return @sorted_locations; } -# Function to get the continent code of a given country code. -sub get_continent_code($$) { - my ($db_handle, $ccode) = @_; - - # Omit the continent code. - my $continent_code = &Location::get_continent_code($db_handle, $ccode); - - return $continent_code; -} - -# Function to flush all exported GeoIP locations. -sub flush_exported_locations () { - # Check if the xt_geoip_db_directory exists. - if (-e $xt_geoip_db_directory) { - # Perform a direcory listing. - opendir (DIR, $xt_geoip_db_directory) or die "Could not open $xt_geoip_db_directory. $!\n"; - - # Loop through the files. - while (my $file = readdir(DIR)) { - # Check if the element is a file. - if (-f "$xt_geoip_db_directory/$file") { - # Delete it. - unlink("$xt_geoip_db_directory/$file"); - } - } - } -} - -# Function which calls location-exporter to export a given array -# of locations. -sub export_locations (\@) { - my @locations = @{ shift() }; - - # String to store the given locations and pass it to the exporter tool. - my $locations_string; - - # Only export IPv4 addresses. - my $family = "--family=ipv4"; - - # Specify xt_geoip as output format. - my $format = "--format=xt_geoip"; - - # Location export command. - my @command = ("/usr/bin/location-exporter", "--directory=$xt_geoip_db_directory", "$format", "$family"); - - # Check if the export directory exists, otherwise create it. - unless (-d $xt_geoip_db_directory) { mkdir $xt_geoip_db_directory }; - - # Loop through the array of locations which needs to be exported. - foreach my $location (@locations) { - # Add location to the command array. - push(@command, $location); - } - - # Execute location-exporter to export the requested country codes. - system(@command) == 0 - or die "@command failed: $?"; -} - 1;