From patchwork Sat Oct 17 01:57:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Spencer Norton X-Patchwork-Id: 10395 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 (secp384r1 raw public key) server-digest SHA384 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mail01.haj.ipfire.org", Issuer "YR1" (not verified)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4j64hS72ZXz3wjT for ; Sat, 17 Oct 2026 01:58:00 +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) (Client CN "mail02.haj.ipfire.org", Issuer "YE2" (not verified)) by mail01.ipfire.org (Postfix) with ESMTPS id 4j64hR3G46z4Nx for ; Sat, 17 Oct 2026 01:57:59 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [IPv6:::1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4j64hR0wClz36Vn for ; Sat, 17 Oct 2026 01:57:59 +0000 (UTC) X-Original-To: location@lists.ipfire.org 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) (Client CN "mail01.haj.ipfire.org", Issuer "YR1" (not verified)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4j64hQ355nz2xJk for ; Sat, 17 Oct 2026 01:57:58 +0000 (UTC) Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azlp170120001.outbound.protection.outlook.com [IPv6:2a01:111:f403:c107::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.protection.outlook.com", Issuer "DigiCert SHA2 Secure Server CA" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4j64hP0fPjz3rB for ; Sat, 17 Oct 2026 01:57:57 +0000 (UTC) Authentication-Results: mail01.ipfire.org; dkim=pass header.d=norvitech.onmicrosoft.com header.s=selector1-norvitech-onmicrosoft-com header.b=EhdnBzR3; dmarc=none; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (mail01.ipfire.org: domain of spencer.norton@norvi.tech designates 2a01:111:f403:c107::1 as permitted sender) smtp.mailfrom=spencer.norton@norvi.tech ARC-Seal: i=2; a=rsa-sha256; d=lists.ipfire.org; s=202003rsa; cv=pass; t=1792202277; b=fnGCRlZPPR4lDSOKNpK07vI/Ng6LfPK6kP9HBi8axF8OEHe44gxQ7/65hwFj5K6nXaTkNu IUKH5cJg2LAwPBP1IlrxYXZrz7+FV+D/A98cGKSSMmqL9KsuM/+IoYXwp7nGTYyVU89lJ6 9FoduMAhjWQ84VO3639QWLQjFv7TgBa+3qj2dqwuIYDQJNQ6hyksfdjI+xfk6wJQzQTi2v e4CZbx0EIv2E6P2R6bOQwTOJ6yNf8nwrjUqnO1sdWMHPPWPHgLgtC+fV2I5ObudiNGdBd9 J4/nvB/5PD/GKA0WRC3d/1m6ZJOdXi13WLIVsFGBH4fZ3Qtpb46XRyQUEaMG+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1792202277; h=from:from: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:dkim-signature; bh=rXqbrZVHARDfA44TSZt+WJ0nzQ8PmYY5WHHOt+Jd9r0=; b=N96eY5drKm8uyHZaVEqiVYcNKpfV162Th8nDyz3rDDZ4fAguGQ4FayITG3E1T+zylLzpZb fbod7hNl1o8YxJwDFyiBJrGWknYGILeM1fKy+YauBlmw+GwM/CCLxe38u9qxikkt1X/dBE e4guMgko9qSHS7lTZn7mFPnOxSYjOveW06yr6QEeA/5DDyCBTzgDvkpSON1xDD0L8yEzBn VMKvE1nBBMu+1y5j+5xmSH+oOvMi6LoNzeBn3eHOnA3Zfc2/4NoLtLjBrtgqh3D3Vr2Vqp YeM0zBfuX62rnNilhTdh/TQKSv4yDo0YGxQjA589cmeBqFJb0jOcykWaty/jOQ== ARC-Authentication-Results: i=2; mail01.ipfire.org; dkim=pass header.d=norvitech.onmicrosoft.com header.s=selector1-norvitech-onmicrosoft-com header.b=EhdnBzR3; dmarc=none; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (mail01.ipfire.org: domain of spencer.norton@norvi.tech designates 2a01:111:f403:c107::1 as permitted sender) smtp.mailfrom=spencer.norton@norvi.tech ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F6Oo5Vm34U/fwBIdN/0cN89KC68bYSb0HaUjjK108w607CKITRkVWQhxUtP61B3a5Do9T+OoE0r0VdWESA9eA8je3MoaQYiJlLP2bwgFGOadJ4cHjzTQemLEXFa2AmF7J4Ql/Y9L5y8M+mxcwlFakZZHrFr5q3cwVhiP7JpbpibX2v5u1ZXJULSBJE6k084HnuDmClCWUtc7rgHbhp1Igi3uu/TXtGFmPMWKZ++z6kcj5KsF9u6d3VaKbTUvwIy9qD8+kwtuhDLmgUCdueMQFAq3zxnlpvIP4RHSeXUiSFZfkmHskP3WPFt5+QClN8vWe+GhhixqDt7anTqner4ysQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rXqbrZVHARDfA44TSZt+WJ0nzQ8PmYY5WHHOt+Jd9r0=; b=mx/HoEob2h+91Lmje9nU7Lo2FvuEjTqnvR4IWcDD/3ZZR+Q/2iMFuqoWibkiL38iFO0Hu18y3ljT+LHKyWflcnDIthoHFHK9Z2z+TsS8ISMkPdxXf8p8GBX9svhUImbzQCFYdt6135/eWPHgWtoMJzXNYLy7MlROSpqHCmO7n51n6Jr58oduETLI/KmUjEjy3St2cLG9VcdYSaENmF3Al3z+5LnLAtyJUgKGU+I+N5HGlXY+ZCwm13Gpo+UmONdnyE/V0D10aanc2+1DjuhMh9/tbPipPLV18ip+nu70sWWDyj2uWqES9A3GR7gDXSYf2WeIpKFmQ80H5yBafMw1qQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=norvi.tech; dmarc=pass action=none header.from=norvi.tech; dkim=pass header.d=norvi.tech; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=norvitech.onmicrosoft.com; s=selector1-norvitech-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rXqbrZVHARDfA44TSZt+WJ0nzQ8PmYY5WHHOt+Jd9r0=; b=EhdnBzR30CIQk9yE3Lk22UJfdO68MlKgrtmdHgusZfSIr28MQtYZm2phqyQKSGuIS1DlBPHr5Hmb/KPrw5E57FVM5HmsX1BrFqaXCAzXUilit9Ze9rsOUkPYCG0FbNCNNx2nEPKvtuAl1+weXu5PubjINL86RZ9M1rfVqUnybS4= Received: from LV9PR18MB927615.namprd18.prod.outlook.com (2603:10b6:408:373::24) by CH3PR18MB5509.namprd18.prod.outlook.com (2603:10b6:610:15a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.522.17; Sat, 17 Oct 2026 01:57:51 +0000 Received: from LV9PR18MB927615.namprd18.prod.outlook.com ([fe80::28f3:a326:e7b:8044]) by LV9PR18MB927615.namprd18.prod.outlook.com ([fe80::28f3:a326:e7b:8044%6]) with mapi id 15.21.0522.016; Sat, 17 Oct 2026 01:57:51 +0000 From: Spencer Norton To: "location@lists.ipfire.org" CC: Michael Tremer , Accounts Subject: [PATCH] importer: Import IP ranges from Oracle Cloud Infrastructure Thread-Topic: [PATCH] importer: Import IP ranges from Oracle Cloud Infrastructure Thread-Index: AQHdXdrqc52ZAOc7N0y+TxP1hm8b1g== Date: Sat, 17 Oct 2026 01:57:50 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.50.1 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: LV9PR18MB927615:EE_|CH3PR18MB5509:EE_ x-ms-office365-filtering-correlation-id: f09844f4-1de4-45b8-deaa-08df2bf20cfb x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|23010399003|1800799024|376014|366016|6133799003|10067099003|18002099003|261009223027099003|5023799004|38070700021|56012099006; x-microsoft-antispam-message-info: HkCPlVGQz/oQvNa6FWC/kBJrHh54cvbr3qfUyfLQBr5o7WNLauALt2hNeT67yFHUwJTmOZwRSp69mPX0Zlli32RxCMkAjRLX/rWw556hdJlCdJZGsHePu5rwovEu9U6KsQhn8+Ps0y3QJz30XOoCJMkGeBwebMhiDv5EFg7ofrd7hiUGmXsgGvS33oAy9ZDmZ89iBJMHdTsUfjrY1796z0YtN6IxwnxIVw99uVgMUsiatoJwAUBfa5Xmfs06KZ5Ya0gf+l+OazlTl2UVWX+zyrG6ngTDGpfM9S5eIatQGARqtfTuJGUF3nrGTgW1Zs0aVXYoqsDWGgOLYD3NjAnEEmZ4xwVrwmT6MBnUjmgV1Kx1vU7nqSijllAMtK6FXDcnagk93QWrqMMDq8AZMBxzA2peXO2/o69GVmfaatTSDZ9t2Ovd9hJg77jhf7Hod9P3PyM2TbkID+VMmQ6nEynhslg9a/zTqkLEX6UVMxs33duBJXhKhOE9NI6UHilsd9R8zuG5FImDW+4nd3c3OIulKcKvw1qZ/3SkNaJdwv5E/dLz6kjvaNAhqm1cBuFtb3BqvC13fa/19PVnPmJ9B9uYCsliWYvldjYYXzhrz+d1RkDp9xeJPr8dSeC38rQHH/ICK/Fgf1GkFYNV7jzzTnCkAsm/6B6CLKwtssH4jqKW0Uc= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV9PR18MB927615.namprd18.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(1800799024)(376014)(366016)(6133799003)(10067099003)(18002099003)(261009223027099003)(5023799004)(38070700021)(56012099006);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: gp1P2MHps4KefmdaHzVofethWDhudKGidbf1sFUvYJwT+rna1+OXGiulOGy53Ztbg2B516ARhUuDaCkIs5eglOF93G8w9ODFrzk5aoQyhFcRf2XwR9Q8bVuKq9DUk7tsrP9pKM7JPPvMoaR68vjtJewJNJTtZq1rhbgZNWJOxHg63D5XRCPNg1NC8BlbNr9d7UQAJ3gYje/yvxlzF2JQ74QQne5H8z72o38Nvy+df611HuaNZBoPUbgWWvi07ouPEPzqGfrt0zpvYaHw+iIIpHgwnYZmQZ/f/ydXeAYbubB18I19zoZ9ddOhf0drwgbS9pNgsK1qFqFOy1njB9RtFYcmhrV+VqUC+nVDa10JkekrzQMw3nE5LfSQnR/zQ588ZLsgtReWYy9yy3c2NzVAzx8+B5UM7IJGe9tP9826wNuRccq8fGjkspjXx5o38Qift9/pKYxavMJI5jNWuoR/+l7UGjLCYw3lstoUwsZj/wK9cDcl33HCM0w9zxoOFupMf6J5sm/0G5r+Rl5p3JEnn+C6nIPcs7HdzW5Wj3IQS6DIhkxD8ERgu4uTvsDazWjNnDXQ4i3gOoncz4MblUViVRVa/gbBsfE0HXMz0P+t9dbM+pGhBCyX/UghxWslTc25i6Jj2+uvfAFZBnM/NPVdsOMnbtOqjrXHDpdq8kpc59VUkC+wlqb+ixKFjVv6eJo80kMPFPt7VA98y2vFidQmYDmkI3hO0rpP8bSR6LOH2c4Rl/BASGjqgczgZoi/KtkrGplTCP5XXvt74d0HtC0gDDYJTAMERth5atn2RgFWB1x7+ctZW2cKTGtVMFTag6ovd1tcSYh1NTFujb+xVhSktsQDNLpS7MqYTLLbTFpZUceQZyz7veOxKXjZIfjHHE43/c0E1zmF1404N2sFdB81HUZxW78VnlqIxbtCLjE6YxIjqqZJxk9Y4p9fUYoqdOvzna88FXsGNk22+sHc8QcIkba8h1x5xdFFJvqjrniPUwf5xgXrm47nF2anZA3B5RWh/MeO2uajmfpiCHLO0gJ/oTr/Kig36CjZGxufBMsCLuqzKHlsAA/49hLIV0azDdTp5hzsKbpOoGgrjeA/eNDONvoHYqUWMVEF46tGHrbFFE65DQ7MiwMQLRpqefxUW6jrFA47rfXRCGrOEDkKWOIOefaIXGqUtYNEsAQPpHsRsKdLoalo5WgVy5lb853ef+9pUWzrpOYMIiuAgEsCm/QTg9Y4cNvUQVwnfqb+dQnx4oWj5Moa+2F46Gmp3rT1Qh7YZk28GhZYdxnAZx0xxOAl0ZdnLp3tiM5cXjsajhEhb5AEH/yKwAaBHV5lyhOshY/aLK2uE0duXOMl69nhD+7Q4tUNQ/ohM0t97Mtz0soOMI4xMLMq3gWnvQ5JDIAtjTrld4wfJVFShC6NX88OQZ0/Ak1zOJl2m7MRdsBYYsgH82mXfre8Qu0+zrD45hD1/v/tAm4JOoDaG/8Wu/HMPTizqHiZyOkAaYTpogiB/2qIAzzBGaGtMzt4OuE8UPfDaJ8iEaWewZUVCWKyk1klSWnuDo++f8V/CMLzgocBoNuNLIrx4KNiNsqTt6svo2nivYaNPbBX3la+l9ubWe0ncvP5784pbZba2v9y8dH8tahUHMZ3Wngu3F1lSCqp4Dg/gglDZOCdk311d1dmeyR2hgB+8UPRj9nDkUd+Cvsm0viCriRkw7MW6rr772AsElq4YoDj6ZFJ6ySaX0LrUENlxd2IoA14kWFnjjLL/u9IYxqwKiw= Content-ID: <7D2F49F75942C74CBD3AA4453ABEA3C3@namprd18.prod.outlook.com> Precedence: list List-Id: List-Subscribe: , List-Unsubscribe: , List-Post: List-Help: Sender: Mail-Followup-To: MIME-Version: 1.0 X-OriginatorOrg: norvi.tech X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: LV9PR18MB927615.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f09844f4-1de4-45b8-deaa-08df2bf20cfb X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Oct 2026 01:57:50.9566 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9f3f6170-3a3a-4e18-817e-166067666706 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: gRPTJdMj/J0Phmx2TjaAXht5b4Js8Lae7EpufeqYfbgSKmcgjv0V7vL8fseYhg0lXFT9ApOJ99p6Co7h9+toyWZEvb32jv0DepewCSwWuhA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR18MB5509 X-Rspamd-Queue-Id: 4j64hP0fPjz3rB X-Rspamd-Action: no action X-Spamd-Result: default: False [-4.28 / 11.00]; BAYES_HAM(-3.00)[100.00%]; SPF_REPUTATION_SPAM(2.56)[0.85284510071007]; R_DKIM_ALLOW(-1.54)[norvitech.onmicrosoft.com:s=selector1-norvitech-onmicrosoft-com]; ARC_ALLOW(-1.00)[microsoft.com:s=arcselector10001:i=1]; DKIM_REPUTATION(-0.91)[-0.90518840186751]; R_SPF_ALLOW(-0.20)[+ip6:2a01:111:f403:c000::/51:c]; MX_GOOD(-0.10)[norvi-tech.mail.protection.outlook.com]; MIME_GOOD(-0.10)[text/plain]; TO_DN_SOME(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=2]; ASN(0.00)[asn:8075, ipnet:2a01:111:f000::/36, country:US]; MIME_TRACE(0.00)[0:+]; IP_REPUTATION_SPAM(0.00)[asn: 8075(0.27), country: US(-0.01), ip: 2a01:111:f403:c107::(0.00)]; DMARC_NA(0.00)[norvi.tech]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[norvitech.onmicrosoft.com:+] X-Rspamd-Server: mail01.haj.ipfire.org Oracle publishes a machine-readable JSON feed of all public IPv4 ranges allocated across its commercial cloud regions, while RIR WHOIS data for many of those blocks still reflects legacy US, GB, or NO headquarters records rather than the region where the prefixes are deployed. Import Oracle's public_ip_ranges.json feed in update-feeds alongside the existing AWS feed and map each region to its ISO-3166-1 alpha-2 country code per Oracle's regional documentation. Fixes: #12928 - 130.162.250.153 shows up as US, while server is actually in germany. Signed-off-by: Spencer Norton --- man/location-importer.txt | 4 +- src/scripts/location-importer.in | 131 +++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 2 deletions(-) diff --git a/man/location-importer.txt b/man/location-importer.txt index 283a466..e217b8b 100644 --- a/man/location-importer.txt +++ b/man/location-importer.txt @@ -75,8 +75,8 @@ queried with location(1). the database. 'update-feeds [FEED ...]':: - This command updates data from third-party feeds, currently the AWS IP - ranges as well as the Spamhaus DROP and ASN-DROP lists. + This command updates data from third-party feeds, currently the AWS and + OCI IP ranges as well as the Spamhaus DROP and ASN-DROP lists. + If one or more FEED arguments are given, only these feeds will be updated. diff --git a/src/scripts/location-importer.in b/src/scripts/location-importer.in index aad6889..0298f4f 100644 --- a/src/scripts/location-importer.in +++ b/src/scripts/location-importer.in @@ -2180,6 +2180,9 @@ class CLI(object): # AWS IP Ranges ("AWS-IP-RANGES", self._import_aws_ip_ranges, "https://ip-ranges.amazonaws.com/ip-ranges.json"), + # OCI IP Ranges + ("OCI-IP-RANGES", self._import_oci_ip_ranges, "https://docs.oracle.com/en-us/iaas/tools/public_ip_ranges.json"), + # Spamhaus DROP ("SPAMHAUS-DROP", self._import_spamhaus_drop, "https://www.spamhaus.org/drop/drop.txt"), ("SPAMHAUS-DROPV6", self._import_spamhaus_drop, "https://www.spamhaus.org/drop/dropv6.txt"), @@ -2358,6 +2361,134 @@ class CLI(object): """, "%s" % network, name, cc, is_anycast, ) + async def _import_oci_ip_ranges(self, name, f): + # Parse the feed + feed = json.load(f) + + # Set up a dictionary for mapping a region name to a country: + # https://docs.oracle.com/en-us/iaas/Content/General/Concepts/regions.htm + oci_region_country_map = { + # Africa + "af-casablanca-1" : "MA", + "af-johannesburg-1" : "ZA", + + # Asia/Pacific + "ap-batam-1" : "ID", + "ap-chuncheon-1" : "KR", + "ap-delhi-1" : "IN", + "ap-hyderabad-1" : "IN", + "ap-kulai-1" : "MY", + "ap-kulai-2" : "MY", + "ap-melbourne-1" : "AU", + "ap-mumbai-1" : "IN", + "ap-osaka-1" : "JP", + "ap-seoul-1" : "KR", + "ap-singapore-1" : "SG", + "ap-singapore-2" : "SG", + "ap-sydney-1" : "AU", + "ap-tokyo-1" : "JP", + + # Canada + "ca-montreal-1" : "CA", + "ca-toronto-1" : "CA", + + # Europe + "eu-amsterdam-1" : "NL", + "eu-dublin-3" : "IE", + "eu-frankfurt-1" : "DE", + "eu-jovanovac-1" : "RS", + "eu-madrid-1" : "ES", + "eu-madrid-3" : "ES", + "eu-marseille-1" : "FR", + "eu-milan-1" : "IT", + "eu-paris-1" : "FR", + "eu-stockholm-1" : "SE", + "eu-turin-1" : "IT", + "eu-zurich-1" : "CH", + "uk-cardiff-1" : "GB", + "uk-london-1" : "GB", + + # Middle East + "il-jerusalem-1" : "IL", + "me-abudhabi-1" : "AE", + "me-dubai-1" : "AE", + "me-jeddah-1" : "SA", + "me-riyadh-1" : "SA", + + # Mexico + "mx-monterrey-1" : "MX", + "mx-queretaro-1" : "MX", + + # South America + "sa-bogota-1" : "CO", + "sa-riodejaneiro-2" : "BR", + "sa-santiago-1" : "CL", + "sa-saopaulo-1" : "BR", + "sa-valparaiso-1" : "CL", + "sa-vinhedo-1" : "BR", + } + + for item in feed.get("regions", []): + # Fetch the region + region = item.get("region", "") + + # Set some defaults + cc = None + is_anycast = False + + # Fetch the CC from the dictionary + try: + cc = oci_region_country_map[region] + + # If we couldn't find anything, let's try something else... + except KeyError as e: + # Everything that starts with us- is probably in the United States + if region.startswith("us-"): + cc = "US" + + # Everything that starts with uk- is probably in the United Kingdom + elif region.startswith("uk-"): + cc = "GB" + + # Log a warning for anything else + else: + log.warning("%s: Could not determine country code for OCI region %s" \ + % (name, region)) + continue + + for prefix in item.get("cidrs", []): + # Fetch network + network = prefix.get("cidr") + + # Parse the network + try: + network = ipaddress.ip_network(network) + except ValueError as e: + log.warning("%s: Unable to parse prefix %s" % (name, network)) + continue + + # Sanitize parsed networks... + if not self._check_parsed_network(network): + continue + + # Write to database + self.db.execute(""" + INSERT INTO + network_feeds + ( + network, + source, + country, + is_anycast + ) + VALUES + ( + %s, %s, %s, %s + ) + ON CONFLICT (network, source) DO NOTHING + """, "%s" % network, name, cc, is_anycast, + ) + async def _import_spamhaus_drop(self, name, f): """ Import Spamhaus DROP IP feeds