From patchwork Thu Jan 10 23:00:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 2027 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail01.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web07.i.ipfire.org (Postfix) with ESMTPS id C10D585D3E7 for ; Thu, 10 Jan 2019 12:00:41 +0000 (GMT) Received: from mail01.i.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 551F3219908E; Thu, 10 Jan 2019 12:00:41 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201801; t=1547121641; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id: list-unsubscribe:list-subscribe:list-post; bh=Pc68SM4TGYc8iU3i8x6L+avpSMujcvGWSs2KQHZP2qM=; b=UFHfa2R37VGd4EmZ0A/qO9eaD0i2TFWLIyBOmQE1G2QiW3+LBYkuNmw9dZbFgemegQJ0W4 R28/Q8PLTZrT4w9weRl9vhnCqnl0f5GtC+qPspscDFYGcpqJFxfrTTIyzBb/M6w32eGZBl w0zFjYG5Ia4GmOWCxIf4W8zODyPIO/8BnwqdgxFtTxLQXg4IZf5kMggdMILngnevDwB+Zf xry64kTveNMQUJ/FeonJhzze9w5kBVkU1o+ENIa/Khl2zEs+Zs+WilP7pVu5jOt3sNWS3S SwD3QIczM63bPSJN5gIHAd8TyRRY5z4mQjd2pfmRSzp1P77azg8QHNUZ/2RY/w== Received: from tuxedo.stevee (unknown [46.125.249.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 3093E21A7C7B; Thu, 10 Jan 2019 12:00:35 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201801; t=1547121635; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pc68SM4TGYc8iU3i8x6L+avpSMujcvGWSs2KQHZP2qM=; b=z3/TCklOnj0V6aooGlUJP2kvf8TrictVx6WcSYc8yH3LdHNjZxmOJE5+mrT1+5hepI5Qg8 ZNjAEyRcHEW1WM4EmfLxYYwCg8Aq6gTJIzLQeHeclaCyJ5R+wczZA78MoMsquSjuMPJO+t 7ZI1Sg3LzCzgWC6Hfofxq4d+3p93d762zBn9TabBfQHhfte+8pt2ZZ4x0oe6PzgPpJK32+ xI24Cej7wtFUC6gzV39L8A5LTDghZytw4j49OduiGzwAAQ4a/gf9azA7/HkYTkv7e4Nr2h ooiwjBPfTxydMQRkgl59VZLOVuNrLl5T2uQ5dun7J2YlyexlxFrK7muw+euSog== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 3/6] xtables-addons: Use shipped xt_geoip_build Date: Thu, 10 Jan 2019 13:00:14 +0100 Message-Id: <20190110120017.6595-3-stefan.schantl@ipfire.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190110120017.6595-1-stefan.schantl@ipfire.org> References: <20190110120017.6595-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass smtp.auth=stevee smtp.mailfrom=stefan.schantl@ipfire.org X-Spamd-Result: default: False [-9.09 / 11.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; DKIM_SIGNED(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-2.99)[-0.995,0]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:8412, ipnet:46.124.0.0/15, country:AT]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Status: No, score=-9.09 X-Rspamd-Server: mail01.i.ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Use the shipped xt_geoip_build directly instead of holding a copy in our GIT. Reference #11959 Signed-off-by: Stefan Schantl --- lfs/xtables-addons | 4 ++ src/scripts/xt_geoip_build | 89 -------------------------------------- 2 files changed, 4 insertions(+), 89 deletions(-) delete mode 100644 src/scripts/xt_geoip_build diff --git a/lfs/xtables-addons b/lfs/xtables-addons index a8aba7455..da67aa761 100644 --- a/lfs/xtables-addons +++ b/lfs/xtables-addons @@ -94,6 +94,10 @@ ifeq "$(USPACE)" "1" cd $(DIR_APP) && make $(MAKETUNING) cd $(DIR_APP) && make install + + # Install xt_geoip_build. + cd $(DIR_APP) && install -m 755 GeoIP/xt_geoip_build \ + /usr/local/bin/ else cd $(DIR_APP) && ./configure \ --with-kbuild=/usr/src/linux-$(KVER)/ diff --git a/src/scripts/xt_geoip_build b/src/scripts/xt_geoip_build deleted file mode 100644 index 202156f13..000000000 --- a/src/scripts/xt_geoip_build +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/perl -# -# Converter for MaxMind CSV database to binary, for xt_geoip -# Copyright © Jan Engelhardt, 2008-2011 -# -use Getopt::Long; -use IO::Handle; -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 $target_dir = "."; - -&Getopt::Long::Configure(qw(bundling)); -&GetOptions( - "D=s" => \$target_dir, -); - -if (!-d $target_dir) { - print STDERR "Target directory $target_dir does not exist.\n"; - exit 1; -} - -my $dir = "$target_dir/LE"; -if (!-e $dir && !mkdir($dir)) { - print STDERR "Could not mkdir $dir: $!\n"; - exit 1; -} - -&dump(&collect()); - -sub collect -{ - my %country; - - while (my $row = $csv->getline(*ARGV)) { - if (!defined($country{$row->[4]})) { - $country{$row->[4]} = { - name => $row->[5], - pool_v4 => [], - pool_v6 => [], - }; - } - my $c = $country{$row->[4]}; - - push(@{$c->{pool_v4}}, [$row->[2], $row->[3]]); - - if ($. % 4096 == 0) { - print STDERR "\r\e[2K$. entries"; - } - } - - print STDERR "\r\e[2K$. entries total\n"; - 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($file, $fh_le, $fh_be); - - printf "%5u IPv4 ranges for %s %s\n", - scalar(@{$country->{pool_v4}}), - $iso_code, $country->{name}; - - $file = "$target_dir/LE/".uc($iso_code).".iv4"; - if (!open($fh_le, "> $file")) { - print STDERR "Error opening $file: $!\n"; - exit 1; - } - foreach my $range (@{$country->{pool_v4}}) { - print $fh_le pack("VV", $range->[0], $range->[1]); - #print $fh_be pack("NN", $range->[0], $range->[1]); - } - close $fh_le; -}