mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-21 12:04:56 +02:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5903f4bcfc | ||
![]() |
5e19871613 |
@@ -1,4 +1,4 @@
|
||||
AC_INIT([xtables-addons], [3.1])
|
||||
AC_INIT([xtables-addons], [3.2])
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
@@ -3,6 +3,13 @@ HEAD
|
||||
====
|
||||
|
||||
|
||||
v3.2 (2018-09-07)
|
||||
=================
|
||||
Changes:
|
||||
- rework xt_geoip_build to scan the immediate directory for .csv,
|
||||
not to scan for GeoLite2-Country-CSV_\d+.
|
||||
|
||||
|
||||
v3.1 (2018-08-14)
|
||||
=================
|
||||
Enhancements:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# Converter for MaxMind CSV database to binary, for xt_geoip
|
||||
# Converter for MaxMind (GeoLite2) CSV database to binary, for xt_geoip
|
||||
# Copyright Jan Engelhardt, 2008-2011
|
||||
# Copyright Philip Prindeville, 2018
|
||||
#
|
||||
@@ -16,53 +16,37 @@ my $csv = Text::CSV_XS->new({
|
||||
binary => 1,
|
||||
eol => $/,
|
||||
}); # or Text::CSV
|
||||
my $source_dir = ".";
|
||||
my $target_dir = ".";
|
||||
|
||||
&Getopt::Long::Configure(qw(bundling));
|
||||
&GetOptions(
|
||||
"D=s" => \$target_dir,
|
||||
"S=s" => \$source_dir,
|
||||
);
|
||||
|
||||
if (!-d $source_dir) {
|
||||
print STDERR "Source directory \"$source_dir\" does not exist.\n";
|
||||
exit 1;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
my %countryId;
|
||||
my %countryName;
|
||||
|
||||
my $dir = findVersion();
|
||||
|
||||
&loadCountries();
|
||||
|
||||
&dump(&collect());
|
||||
|
||||
sub findVersion
|
||||
{
|
||||
my @dirs = ();
|
||||
|
||||
opendir(my $dh, '.') || die "Can't open .: $!\n";
|
||||
|
||||
while (readdir $dh) {
|
||||
if ($_ =~ m/^GeoLite2-Country-CSV_\d{8}$/) {
|
||||
push(@dirs, $_);
|
||||
}
|
||||
}
|
||||
closedir $dh;
|
||||
|
||||
@dirs = sort @dirs;
|
||||
return pop(@dirs);
|
||||
}
|
||||
|
||||
sub loadCountries
|
||||
{
|
||||
my $file = "$dir/GeoLite2-Country-Locations-en.csv";
|
||||
|
||||
sub id; sub cc; sub long; sub ct; sub cn;
|
||||
|
||||
%countryId = ();
|
||||
%countryName = ();
|
||||
|
||||
my $file = "$source_dir/GeoLite2-Country-Locations-en.csv";
|
||||
open(my $fh, '<', $file) || die "Couldn't open list country names\n";
|
||||
|
||||
# first line is headers
|
||||
@@ -152,8 +136,7 @@ sub collect
|
||||
};
|
||||
}
|
||||
|
||||
$file = "$dir/GeoLite2-Country-Blocks-IPv4.csv";
|
||||
|
||||
$file = "$source_dir/GeoLite2-Country-Blocks-IPv4.csv";
|
||||
open($fh, '<', $file) || die "Can't open IPv4 database\n";
|
||||
|
||||
# first line is headers
|
||||
@@ -194,8 +177,7 @@ sub collect
|
||||
# clean up the namespace
|
||||
undef &net; undef &id; undef &rid; undef &proxy; undef &sat;
|
||||
|
||||
$file = "$dir/GeoLite2-Country-Blocks-IPv6.csv";
|
||||
|
||||
$file = "$source_dir/GeoLite2-Country-Blocks-IPv6.csv";
|
||||
open($fh, '<', $file) || die "Can't open IPv6 database\n";
|
||||
|
||||
# first line is headers
|
||||
@@ -281,4 +263,3 @@ sub writeCountry
|
||||
}
|
||||
close $fh;
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,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\-D\fP
|
||||
\fItarget_dir\fP]
|
||||
\fItarget_dir\fP] [\fB\-S\fP \fIsource_dir\fP]
|
||||
.SH Description
|
||||
.PP
|
||||
xt_geoip_build is used to build packed raw representations of the range
|
||||
@@ -16,20 +16,19 @@ required to be loaded into memory. The ranges in the packed database files are
|
||||
also ordered, as xt_geoip relies on this property for its bisection approach to
|
||||
work.
|
||||
.PP
|
||||
It expects to find a directory named
|
||||
.IR GeoLite2-Country-CSV_YYYYMMDD
|
||||
in the current directory, and will select the most recent if multiple
|
||||
instances are found. The
|
||||
.IR xt_geoip_dl
|
||||
script can be used to populate this directory.
|
||||
.PP
|
||||
Since the script is usually installed to the libexec directory of the
|
||||
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\-D\fP \fItarget_dir\fP
|
||||
Specify a target directory into which the files are to be put.
|
||||
Specifies the target directory into which the files are to be put. Defaults to ".".
|
||||
.TP
|
||||
\fB\-S\fP \fIsource_dir\fP
|
||||
Specifies the source directory from which to read the three files by the name
|
||||
of \fBGeoLite2\-Country\-Blocks\-IPv4.csv\fP,
|
||||
\fBGeoLite2\-Country\-Blocks\-IPv6.csv\fP and
|
||||
\fBGeoLite2\-Country\-Locations\-en.csv\fP. Defaults to ".".
|
||||
.SH Application
|
||||
.PP
|
||||
Shell commands to build the databases and put them to where they are expected:
|
||||
|
@@ -1,4 +1,4 @@
|
||||
.TH xtables-addons 8 "Windows" "" "v3.1 (2018-08-14)"
|
||||
.TH xtables-addons 8 "Retro" "" "v3.2 (2018-09-07)"
|
||||
.SH Name
|
||||
Xtables-addons \(em additional extensions for iptables, ip6tables, etc.
|
||||
.SH Targets
|
||||
|
Reference in New Issue
Block a user