[PATCH v3 1/2] Put database into country subdirectory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Philip Prindeville <philipp@xxxxxxxxxxxxxxxxxxxxx>

Signed-off-by: Philip Prindeville <philipp@xxxxxxxxxxxxxxxxxxxxx>
---
 geoip/xt_geoip_build | 7 ++++++-
 geoip/xt_geoip_fetch | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/geoip/xt_geoip_build b/geoip/xt_geoip_build
index 3b158753d9cc962b9ff3dedb014e4752548b3d32..07778ab4a5f2b76c3a5c1b9a977b9a7a724ab6fe 100755
--- a/geoip/xt_geoip_build
+++ b/geoip/xt_geoip_build
@@ -34,6 +34,11 @@ if (!-d $target_dir) {
 	exit 1;
 }
 
+if (!-d "$target_dir/cc" && !mkdir "$target_dir/cc") {
+	print STDERR "Couldn't create country subdirectory.\n";
+	exit 1;
+}
+
 my %countryId;
 my %countryName;
 &loadCountries();
@@ -247,7 +252,7 @@ sub writeCountry
 		($family == AF_INET ? '4' : '6'),
 		$iso_code, $name;
 
-	my $file = "$target_dir/".uc($iso_code).".iv".($family == AF_INET ? '4' : '6');
+	my $file = "$target_dir/cc/".uc($iso_code).".iv".($family == AF_INET ? '4' : '6');
 	if (!open($fh, '>', $file)) {
 		print STDERR "Error opening $file: $!\n";
 		exit 1;
diff --git a/geoip/xt_geoip_fetch b/geoip/xt_geoip_fetch
index 4a35760b77c9509347a3846f37eeb9574aeb9883..8ca475c46f9cc3d821737d2088b3393429e158d8 100755
--- a/geoip/xt_geoip_fetch
+++ b/geoip/xt_geoip_fetch
@@ -38,7 +38,7 @@ foreach my $cc (@ARGV) {
 		exit 1;
 	}
 
-	my $file = $target_dir . '/' . uc($cc) . '.iv4';
+	my $file = "$target_dir/cc/".uc($cc).'.iv4';
 
 	if (! -f $file) {
 		printf STDERR "Can't find data for country '$cc'\n";
-- 
2.17.2




[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux