aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmish2020-08-06 20:32:40 +0530
committerAmish2020-08-06 20:32:40 +0530
commitcf0743d65527fdd7e93a73b6fc91dc127b716685 (patch)
tree1b06d8e0977bede277076bcb0696ca7c47098f49
parent6f4ef55e36c499355bbd088ed66bb0628e838052 (diff)
downloadaur-cf0743d65527fdd7e93a73b6fc91dc127b716685.tar.gz
Rebuild with latest DB-IP database
-rw-r--r--.SRCINFO12
-rw-r--r--.gitignore5
-rw-r--r--PKGBUILD18
-rw-r--r--mmcsv_geoip_build1
-rw-r--r--xt_geoip_build128
5 files changed, 145 insertions, 19 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 289cde55257b..650bfb803ab0 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,21 +1,21 @@
pkgbase = xtables-geoip-db
pkgdesc = GeoIP Database for xtables
- pkgver = 2.0
- pkgrel = 6
+ pkgver = 2.1
+ pkgrel = 1
url = https://db-ip.com/db/download/ip-to-country-lite
arch = any
license = BSD
license = GPL
makedepends = perl-text-csv-xs
makedepends = perl-net-cidr-lite
- source = dbip-country-lite-2020-07.csv.gz::https://download.db-ip.com/free/dbip-country-lite-2020-07.csv.gz
- source = xt_geoip_build-3.9::https://sourceforge.net/p/xtables-addons/xtables-addons/ci/v3.9/tree/geoip/xt_geoip_build?format=raw
+ source = dbip-country-lite-2020-08.csv.gz::https://download.db-ip.com/free/dbip-country-lite-2020-08.csv.gz
source = README
+ source = xt_geoip_build
source = mmcsv_geoip_build
sha256sums = SKIP
- sha256sums = 6bd72c83973a104481c1bdfb634916ca1c446924d1307e69088702dfe77b7dcf
sha256sums = bd1dbbacdde0c6b63b15c00a9b3cecada7c95bbd72cd2f7a336106fce53cddbd
- sha256sums = 216cb5a8c018c9db1cbff6b8a788d71d08f1d23dbb4ae60d318fc62fab1a2b46
+ sha256sums = d47c67f8126915ef4f326befa3b3b50903e335efdc52967a401e17749b7b92bd
+ sha256sums = beebf34ac2138e8916eb31450b50d693b174fe2f54626d8a858521b7391cbefc
pkgname = xtables-geoip-db
diff --git a/.gitignore b/.gitignore
index cce2085886b4..2c128538a74c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,8 +2,7 @@ src
pkg
dbip-country-lite-*.csv.gz
GeoLite2-Country-CSV-*.zip
-xt_geoip_build-*
xtables-geoip-db-*.tar.gz
-*-any.pkg.tar.xz
-*-any.pkg.tar.xz.sig
+*-any.pkg.tar.zst
+*-any.pkg.tar.zst.sig
geoip.license.key
diff --git a/PKGBUILD b/PKGBUILD
index c807d7c8bfb7..21aad74af5c5 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,12 +1,11 @@
# Maintainer: Amish <contact at via dot aur>
pkgname=xtables-geoip-db
-pkgver=2.0
-pkgrel=6
+pkgver=2.1
+pkgrel=1
pkgdesc="GeoIP Database for xtables"
arch=('any')
license=('BSD' 'GPL')
makedepends=('perl-text-csv-xs' 'perl-net-cidr-lite')
-_xtver=3.9
_geoip_date=`date +%Y-%m`
# if you want to use MaxMind DB instead of DB-IP then, get license key from
@@ -26,21 +25,20 @@ else
_dbsource="MaxMind GeoLite2"
_dblink="https://www.maxmind.com"
fi
-source+=("xt_geoip_build-${_xtver}::https://sourceforge.net/p/xtables-addons/xtables-addons/ci/v${_xtver}/tree/geoip/xt_geoip_build?format=raw"
- "README"
- "mmcsv_geoip_build")
+source+=('README'
+ 'xt_geoip_build'
+ 'mmcsv_geoip_build')
sha256sums=('SKIP'
- '6bd72c83973a104481c1bdfb634916ca1c446924d1307e69088702dfe77b7dcf'
'bd1dbbacdde0c6b63b15c00a9b3cecada7c95bbd72cd2f7a336106fce53cddbd'
- '216cb5a8c018c9db1cbff6b8a788d71d08f1d23dbb4ae60d318fc62fab1a2b46')
+ 'd47c67f8126915ef4f326befa3b3b50903e335efdc52967a401e17749b7b92bd'
+ 'beebf34ac2138e8916eb31450b50d693b174fe2f54626d8a858521b7391cbefc')
package() {
echo Using ${_dbsource} GeoIP database
install -d -m 755 "${pkgdir}"/usr/share/xt_geoip
if [[ -z "${_maxmind_key}" ]]; then
cd "${srcdir}"
- ln -s dbip-country-lite-${_geoip_date}.csv dbip-country-lite.csv
- perl "${srcdir}"/xt_geoip_build-${_xtver} -D "${pkgdir}"/usr/share/xt_geoip
+ perl "${srcdir}"/xt_geoip_build -D "${pkgdir}"/usr/share/xt_geoip -i dbip-country-lite-${_geoip_date}.csv
else
cd "${srcdir}"/GeoLite2-Country-CSV_*
perl "${srcdir}"/mmcsv_geoip_build -D "${pkgdir}"/usr/share/xt_geoip
diff --git a/mmcsv_geoip_build b/mmcsv_geoip_build
index 3b158753d9cc..2dd9cbe13faa 100644
--- a/mmcsv_geoip_build
+++ b/mmcsv_geoip_build
@@ -1,4 +1,5 @@
#!/usr/bin/perl
+# Source: https://sourceforge.net/p/xtables-addons/xtables-addons/ci/v3.7/tree/geoip/xt_geoip_build?format=raw
#
# Converter for MaxMind (GeoLite2) CSV database to binary, for xt_geoip
# Copyright Jan Engelhardt, 2008-2011
diff --git a/xt_geoip_build b/xt_geoip_build
new file mode 100644
index 000000000000..7fd9eeea8ac4
--- /dev/null
+++ b/xt_geoip_build
@@ -0,0 +1,128 @@
+#!/usr/bin/perl
+# Source: https://inai.de/files/xtables-addons/xtables-addons-3.10.tar.xz
+#
+# Converter for DBIP (Country Lite) CSV database to binary, for xt_geoip
+# Copyright Jan Engelhardt, 2008-2011
+# Copyright Philip Prindeville, 2018
+# Copyright Arjen de Korte, 2020
+#
+use Getopt::Long;
+use Net::CIDR::Lite;
+use Socket qw(AF_INET AF_INET6 inet_pton);
+use warnings;
+use Text::CSV_XS; # or trade for Text::CSV
+use strict;
+
+my $csv = Text::CSV_XS->new({
+ allow_whitespace => 1,
+ binary => 1,
+ eol => $/,
+}); # or Text::CSV
+my $quiet = 0;
+my $input_file = "dbip-country-lite.csv";
+my $target_dir = ".";
+
+&Getopt::Long::Configure(qw(bundling));
+&GetOptions(
+ "D=s" => \$target_dir,
+ "i=s" => \$input_file,
+ "q" => \$quiet,
+ "s" => sub { $target_dir = "/usr/share/xt_geoip"; },
+);
+
+if (!-d $target_dir) {
+ print STDERR "Target directory \"$target_dir\" does not exist.\n";
+ exit 1;
+}
+
+&dump(&collect());
+
+sub collect
+{
+ my ($file, $fh, $row);
+ my (%country);
+ if ($input_file eq "-") {
+ open($fh, "<&STDIN");
+ } else {
+ open($fh, "<", $input_file) || die "Cannot open $input_file: $!\n";
+ }
+
+ while ($row = $csv->getline($fh)) {
+ my ($cc, $range);
+
+ $cc = $row->[2];
+ $range = $row->[0] . "-" . $row->[1];
+
+ if (!exists($country{$cc})) {
+ $country{$cc} = { pool_v4 => Net::CIDR::Lite->new(), pool_v6 => Net::CIDR::Lite->new() };
+ }
+
+ if (index($range, '.') > 0) {
+ $country{$cc}->{pool_v4}->add_range($range);
+ }
+
+ if (index($range, ':') > 0) {
+ $country{$cc}->{pool_v6}->add_range($range);
+ }
+
+ if (!$quiet && $. % 4096 == 0) {
+ print STDERR "\r\e[2K$. entries";
+ }
+ }
+
+ print STDERR "\r\e[2K$. entries total\n" unless ($quiet);
+
+ close($fh);
+
+ return \%country;
+}
+
+sub dump
+{
+ my $country = shift @_;
+
+ foreach my $iso_code (sort keys %{$country}) {
+ &dump_one($iso_code, $country->{$iso_code});
+ }
+}
+
+sub dump_one
+{
+ my($iso_code, $country) = @_;
+ my @ranges;
+
+ @ranges = $country->{pool_v4}->list_range();
+
+ writeCountry($iso_code, AF_INET, @ranges);
+
+ @ranges = $country->{pool_v6}->list_range();
+
+ writeCountry($iso_code, AF_INET6, @ranges);
+}
+
+sub writeCountry
+{
+ my ($iso_code, $family, @ranges) = @_;
+ my $fh;
+
+ printf "%5u IPv%s ranges for %s\n",
+ scalar(@ranges),
+ ($family == AF_INET ? '4' : '6'),
+ $iso_code unless ($quiet);
+
+ my $file = "$target_dir/".uc($iso_code).".iv".($family == AF_INET ? '4' : '6');
+ if (!open($fh, '>', $file)) {
+ print STDERR "Error opening $file: $!\n";
+ exit 1;
+ }
+
+ binmode($fh);
+
+ foreach my $range (@ranges) {
+ my ($start, $end) = split('-', $range);
+ $start = inet_pton($family, $start);
+ $end = inet_pton($family, $end);
+ print $fh $start, $end;
+ }
+ close $fh;
+}