[PATCH v2 5/5] 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>
---
 extensions/libxt_geoip.c | 4 ++--
 geoip/xt_geoip_build     | 7 ++++++-
 geoip/xt_geoip_fetch     | 2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/extensions/libxt_geoip.c b/extensions/libxt_geoip.c
index 44e2dfd4c16be360aa493d965a52ea419706e1df..454f35ce6d63e991608ed1ba1d91e34e05b17bbd 100644
--- a/extensions/libxt_geoip.c
+++ b/extensions/libxt_geoip.c
@@ -102,9 +102,9 @@ geoip_get_subnets(const char *code, uint32_t *count, uint8_t nfproto)
 
 	/* Use simple integer vector files */
 	if (nfproto == NFPROTO_IPV6) {
-		snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/%s.iv6", code);
+		snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/cc/%s.iv6", code);
 	} else {
-		snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/%s.iv4", code);
+		snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/cc/%s.iv4", code);
 	}
 
 	if ((fd = open(buf, O_RDONLY)) < 0) {
diff --git a/geoip/xt_geoip_build b/geoip/xt_geoip_build
index 84fe8f3a5c426a31d0502fc816eea6c4942d016c..bded2d36bd16e48d9ce129141c33b4ac17593865 100755
--- a/geoip/xt_geoip_build
+++ b/geoip/xt_geoip_build
@@ -28,6 +28,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;
 
@@ -265,7 +270,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 a598335164a227ecc65fd180fb744b4a93976590..198207aa52c11c89fd818c64adfad62b69371626 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.14.3

--
To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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