mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-21 03:54:59 +02:00
geoip: remove -b option, always build both endianesses
This commit is contained in:
@@ -12,19 +12,24 @@ use strict;
|
|||||||
|
|
||||||
my %country;
|
my %country;
|
||||||
my $csv = Text::CSV_XS->new({binary => 0, eol => $/}); # or Text::CSV
|
my $csv = Text::CSV_XS->new({binary => 0, eol => $/}); # or Text::CSV
|
||||||
my $mode = "VV";
|
|
||||||
my $target_dir = ".";
|
my $target_dir = ".";
|
||||||
|
|
||||||
&Getopt::Long::Configure(qw(bundling));
|
&Getopt::Long::Configure(qw(bundling));
|
||||||
&GetOptions(
|
&GetOptions(
|
||||||
"D=s" => \$target_dir,
|
"D=s" => \$target_dir,
|
||||||
"b" => sub { $mode = "NN"; },
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!-d $target_dir) {
|
if (!-d $target_dir) {
|
||||||
print STDERR "Target directory $target_dir does not exist.\n";
|
print STDERR "Target directory $target_dir does not exist.\n";
|
||||||
exit 1;
|
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)) {
|
while (my $row = $csv->getline(*ARGV)) {
|
||||||
if (!defined($country{$row->[4]})) {
|
if (!defined($country{$row->[4]})) {
|
||||||
@@ -40,13 +45,26 @@ while (my $row = $csv->getline(*ARGV)) {
|
|||||||
print STDERR "\r\e[2K$. entries total\n";
|
print STDERR "\r\e[2K$. entries total\n";
|
||||||
|
|
||||||
foreach my $iso_code (sort keys %country) {
|
foreach my $iso_code (sort keys %country) {
|
||||||
|
my($file, $fh_le, $fh_be);
|
||||||
|
|
||||||
printf "%5u ranges for %s %s\n",
|
printf "%5u ranges for %s %s\n",
|
||||||
scalar(@{$country{$iso_code}{pool}}),
|
scalar(@{$country{$iso_code}{pool}}),
|
||||||
$iso_code, $country{$iso_code}{name};
|
$iso_code, $country{$iso_code}{name};
|
||||||
|
|
||||||
open(my $fh, "> $target_dir/".uc($iso_code).".iv0");
|
$file = "$target_dir/LE/".uc($iso_code).".iv0";
|
||||||
foreach my $range (@{$country{$iso_code}{pool}}) {
|
if (!open($fh_le, "> $file")) {
|
||||||
print $fh pack($mode, $range->[0], $range->[1]);
|
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
|
xt_geoip_build \(em convert GeoIP.csv to packed format for xt_geoip
|
||||||
.SH Syntax
|
.SH Syntax
|
||||||
.PP
|
.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...]
|
\fItarget_dir\fP] [\fIfile\fP...]
|
||||||
.SH Description
|
.SH Description
|
||||||
.PP
|
.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.
|
script requires it to be called with a path.
|
||||||
.PP Options
|
.PP Options
|
||||||
.TP
|
.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
|
\fB\-D\fP \fItarget_dir\fP
|
||||||
Specify a target directory into which the files are to be put.
|
Specify a target directory into which the files are to be put.
|
||||||
.SH Application
|
.SH Application
|
||||||
.PP
|
.PP
|
||||||
Shell commands to build the databases and put them to where they are expected:
|
Shell commands to build the databases and put them to where they are expected:
|
||||||
.PP
|
.PP
|
||||||
xt_geoip_build -D /usr/share/xt_geoip/LE
|
xt_geoip_build -D /usr/share/xt_geoip
|
||||||
.PP
|
|
||||||
xt_geoip_build -bD /usr/share/xt_geoip/BE
|
|
||||||
.SH See also
|
.SH See also
|
||||||
.PP
|
.PP
|
||||||
xt_geoip_dl(1)
|
xt_geoip_dl(1)
|
||||||
|
Reference in New Issue
Block a user