aboutsummarylogtreecommitdiffstats
path: root/xt_geoip_build.patch
blob: 6036c594ac958dfcb095c6090d1c1d0d86359fa3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
--- xt_geoip_build	2020-03-14 11:20:21.998904611 +0530
+++ xt_geoip_build.nft	2020-03-14 11:30:44.649342148 +0530
@@ -108,19 +108,19 @@
 		($family == AF_INET ? '4' : '6'),
 		$iso_code;
 
-	my $file = "$target_dir/".uc($iso_code).".iv".($family == AF_INET ? '4' : '6');
+	my $file = "$target_dir/".uc($iso_code).".ipv".($family == AF_INET ? '4' : '6');
 	if (!open($fh, '>', $file)) {
 		print STDERR "Error opening $file: $!\n";
 		exit 1;
 	}
 
-	binmode($fh);
-
+	print $fh "define geoip".($family == AF_INET ? '4' : '6')."_iso_country_".uc($iso_code)." = {\n";
 	foreach my $range (@ranges) {
 		my ($start, $end) = split('-', $range);
-		$start = inet_pton($family, $start);
-		$end = inet_pton($family, $end);
-		print $fh $start, $end;
+		print $fh "    $start";
+		print $fh "-$end" if ($start ne $end);
+		print $fh ",\n";
 	}
+	print $fh "}\n";
 	close $fh;
 }