From patchwork Sun Dec 8 10:11:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 2631 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 47W2Dg3TBvz3yYP for ; Sun, 8 Dec 2019 10:12:03 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 47W2Dg0jYYz2bC; Sun, 8 Dec 2019 10:12:03 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 47W2Df4qmvz2yfJ; Sun, 8 Dec 2019 10:12:02 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 47W2Dc6spwz2yN4; Sun, 8 Dec 2019 10:12:00 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 47W2Dc0dyCz2KY; Sun, 8 Dec 2019 10:11:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909rsa; t=1575799920; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=HRutM9KW1SPqLEBDupA4oGAaoTWpoeM4NWnyIvOpRCg=; b=j0uRqIhxblUUQ61X1LdKQcmwsrumwnlBAFn3cGRBGTGjGab5MsYkBu+q3/nX6zUVUZ+o7j KYwOk09WnKOzzT4z/Zll89N4KNx8v83abepSEDSUjOvA7+nRlFLGqtMhkNTUHRHo5CiYQL 1cKJel9TdfFPZ3BHePbQKnlBLfBoghhp8v2lqpns20UmgE7rUyJAXFTjc80+ARnsAI/Znb Mmk0VLqvQGWQVYnpO1x4+XSlRUc2Tvt9rdTDeKc3bYCGs/uJskCicga4zVWCbLXx3Elq4a ICmf+bFkF9X8O5eKd6pSbZc97nz6zKy3Ii4+SYvLHPnpC37krO7r428lBTsXlA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909ed25519; t=1575799920; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=HRutM9KW1SPqLEBDupA4oGAaoTWpoeM4NWnyIvOpRCg=; b=dLcwxG2Liah1L2W1nK/u5bNimcISK4XbXzaO0S3ngpf/1kIiLoxsfTy1yjDDcZfMizMNob XRsY56KsTbCokeDA== From: Stefan Schantl To: location@lists.ipfire.org Subject: [PATCH] location-exporter: Allow exporting by family Date: Sun, 8 Dec 2019 11:11:56 +0100 Message-Id: <20191208101156.27524-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-BeenThere: location@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: development@lists.ipfire.org Errors-To: location-bounces@lists.ipfire.org Sender: "Location" Signed-off-by: Stefan Schantl --- src/python/location-exporter.in | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/python/location-exporter.in b/src/python/location-exporter.in index 421ed02..3074b90 100644 --- a/src/python/location-exporter.in +++ b/src/python/location-exporter.in @@ -177,8 +177,8 @@ class Exporter(object): self.db = db self.writer = writer - def export(self, directory, countries, asns): - for family in (socket.AF_INET6, socket.AF_INET): + def export(self, directory, families, countries, asns): + for family in families: log.debug("Exporting family %s" % family) writers = {} @@ -242,6 +242,9 @@ class CLI(object): # directory parser.add_argument("--directory", help=_("Output directory"), required=True) + # family + parser.add_argument("--family", help=_("Specify address family"), choices=("ipv6", "ipv4")) + # Countries and Autonomous Systems parser.add_argument("objects", nargs="+") @@ -270,6 +273,14 @@ class CLI(object): def handle_export(self, ns): countries, asns = [], [] + # Translate family + if ns.family == "ipv6": + families = [ socket.AF_INET6 ] + elif ns.family == "ipv4": + families = [ socket.AF_INET ] + else: + families = [ socket.AF_INET6, socket.AF_INET ] + for object in ns.objects: if object.startswith("AS"): try: @@ -299,7 +310,7 @@ class CLI(object): assert writer e = Exporter(db, writer) - e.export(ns.directory, countries=countries, asns=asns) + e.export(ns.directory, countries=countries, asns=asns, families=families) def main():