mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-20 19:44:56 +02:00
geoip: remove -b option, always build both endianesses
This commit is contained in:
@@ -12,19 +12,24 @@ use strict;
|
||||
|
||||
my %country;
|
||||
my $csv = Text::CSV_XS->new({binary => 0, eol => $/}); # or Text::CSV
|
||||
my $mode = "VV";
|
||||
my $target_dir = ".";
|
||||
|
||||
&Getopt::Long::Configure(qw(bundling));
|
||||
&GetOptions(
|
||||
"D=s" => \$target_dir,
|
||||
"b" => sub { $mode = "NN"; },
|
||||
);
|
||||
|
||||
if (!-d $target_dir) {
|
||||
print STDERR "Target directory $target_dir does not exist.\n";
|
||||
exit 1;
|
||||
}
|
||||
foreach (qw(LE BE)) {
|
||||
my $dir = "$target_dir/$_";
|
||||
if (!-e $dir && !mkdir($dir)) {
|
||||
print STDERR "Could not mkdir $dir: $!\n";
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
|
||||
while (my $row = $csv->getline(*ARGV)) {
|
||||
if (!defined($country{$row->[4]})) {
|
||||
@@ -40,13 +45,26 @@ while (my $row = $csv->getline(*ARGV)) {
|
||||
print STDERR "\r\e[2K$. entries total\n";
|
||||
|
||||
foreach my $iso_code (sort keys %country) {
|
||||
my($file, $fh_le, $fh_be);
|
||||
|
||||
printf "%5u ranges for %s %s\n",
|
||||
scalar(@{$country{$iso_code}{pool}}),
|
||||
$iso_code, $country{$iso_code}{name};
|
||||
|
||||
open(my $fh, "> $target_dir/".uc($iso_code).".iv0");
|
||||
foreach my $range (@{$country{$iso_code}{pool}}) {
|
||||
print $fh pack($mode, $range->[0], $range->[1]);
|
||||
$file = "$target_dir/LE/".uc($iso_code).".iv0";
|
||||
if (!open($fh_le, "> $file")) {
|
||||
print STDERR "Error opening $file: $!\n";
|
||||
exit 1;
|
||||
}
|
||||
close $fh;
|
||||
$file = "$target_dir/BE/".uc($iso_code).".iv0";
|
||||
if (!open($fh_be, "> $file")) {
|
||||
print STDERR "Error opening $file: $!\n";
|
||||
exit 1;
|
||||
}
|
||||
foreach my $range (@{$country{$iso_code}{pool}}) {
|
||||
print $fh_le pack("VV", $range->[0], $range->[1]);
|
||||
print $fh_be pack("NN", $range->[0], $range->[1]);
|
||||
}
|
||||
close $fh_le;
|
||||
close $fh_be;
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
xt_geoip_build \(em convert GeoIP.csv to packed format for xt_geoip
|
||||
.SH Syntax
|
||||
.PP
|
||||
\fI/usr/libexec/xt_geoip/\fP\fBxt_geoip_build\fP [\fB\-b\fP] [\fB\-D\fP
|
||||
\fI/usr/libexec/xt_geoip/\fP\fBxt_geoip_build\fP [\fB\-D\fP
|
||||
\fItarget_dir\fP] [\fIfile\fP...]
|
||||
.SH Description
|
||||
.PP
|
||||
@@ -23,20 +23,13 @@ xtables-addons package and this is outside $PATH (on purpose), invoking the
|
||||
script requires it to be called with a path.
|
||||
.PP Options
|
||||
.TP
|
||||
\fB\-b\fP
|
||||
The packed database files (file extension .iv0) are normally produced in
|
||||
little-endian format. Use \fB\-b\fP to produce big-endian instead, as is needed
|
||||
on some CPU families such as MIPS, PPC and SPARC.
|
||||
.TP
|
||||
\fB\-D\fP \fItarget_dir\fP
|
||||
Specify a target directory into which the files are to be put.
|
||||
.SH Application
|
||||
.PP
|
||||
Shell commands to build the databases and put them to where they are expected:
|
||||
.PP
|
||||
xt_geoip_build -D /usr/share/xt_geoip/LE
|
||||
.PP
|
||||
xt_geoip_build -bD /usr/share/xt_geoip/BE
|
||||
xt_geoip_build -D /usr/share/xt_geoip
|
||||
.SH See also
|
||||
.PP
|
||||
xt_geoip_dl(1)
|
||||
|
Reference in New Issue
Block a user