From patchwork Tue Sep 22 18:24:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 3480 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) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4BwqW00R0Jz3x5y for ; Tue, 22 Sep 2020 18:25:48 +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 4BwqVv102Vz126; Tue, 22 Sep 2020 18:25:43 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4BwqVt4pdQz30Vt; Tue, 22 Sep 2020 18:25:42 +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 4BwqVs1zbqz2xTN for ; Tue, 22 Sep 2020 18:25:41 +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 4BwqVr38yCzJQ; Tue, 22 Sep 2020 18:25:40 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1600799140; 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=e3Ai4xRuMZqoQhnOy6CxLMbPJa20qchzpBOtoQf2IYQ=; b=Eq5pMhqj7ugPpWXmpJCL8nNEJsY6EUv4CYeddp6zFKKdHe4gDyYpp+SOIB4if2UM2hUXJ+ Mi5JUDj0fQkYk4DQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1600799140; 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=e3Ai4xRuMZqoQhnOy6CxLMbPJa20qchzpBOtoQf2IYQ=; b=C7mJmLLO6bU3tgXKKSkp1Fpbvk0YfwMFFVNWRvpMaVXERsKBJpKrCmc699/Lai3yz6EAvP lOmYhu9oullheYH8p2WY6CJ3su42stMzMI3NSx+2MxIru6vkRV/xBieCdm5mTG1KnQBv2C +KJixDvSkr4W5jU1mXFeKyofa6NIKzBT9kLbQrDwavLV9G7SmirmaZbADRKIJs/239EOCN EE+YZ4YrkutMQKRDtG9pYyghUG1ScK1y6ynOlUUFuRRiUfInt/VQtEJknQNxT01GzDPbyz bRBZYRr4w61adTpUyQ7kghdjvoBkC/LCJRJfHyXdfCBIdDkE3TdB4Aimvw6DdQ== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 01/11] location-functions.pl: Refactor get_locations() function to use the Location module. Date: Tue, 22 Sep 2020 20:24:59 +0200 Message-Id: <20200922182509.18643-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass smtp.mailfrom=stefan.schantl@ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 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" Signed-off-by: Stefan Schantl --- config/cfgroot/location-functions.pl | 30 +++++++++------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/config/cfgroot/location-functions.pl b/config/cfgroot/location-functions.pl index ab99e71d3..a94d5909e 100644 --- a/config/cfgroot/location-functions.pl +++ b/config/cfgroot/location-functions.pl @@ -38,6 +38,9 @@ my %not_iso_3166_location = ( "fx" => "France, Metropolitan" ); +# Array which contains special country codes. +my @special_locations = ( "A1", "A2", "A3" ); + # Directory where the libloc database and keyfile lives. our $location_dir = "/var/lib/location/"; @@ -167,29 +170,14 @@ sub get_full_country_name($) { # Function to get all available locations. sub get_locations() { - my @locations = (); - - # Get listed country codes from ISO 3166-1. - my @locations_lc = &Locale::Codes::Country::all_country_codes(); - - # The Codes::Country module provides the country codes only in lower case. - # So we have to loop over the array and convert them into upper case format. - foreach my $ccode (@locations_lc) { - # Convert the country code to uppercase. - my $ccode_uc = uc($ccode); + # Create libloc database handle. + my $db_handle = &init(); - # Add the converted ccode to the locations array. - push(@locations, $ccode_uc); - } - - # Add locations from not_iso_3166_locations. - foreach my $location (keys %not_iso_3166_location) { - # Convert the location into uppercase. - my $location_uc = uc($location); + # Get locations which are stored in the location database. + my @database_locations = &Location::database_countries($db_handle); - # Add the location to the locations array. - push(@locations, $location_uc); - } + # Merge special locations array and the database locations array. + my @locations = (@special_locations, @database_locations); # Sort locations array in alphabetical order. my @sorted_locations = sort(@locations); From patchwork Tue Sep 22 18:25:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 3479 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) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4BwqW006cwz3x5w for ; Tue, 22 Sep 2020 18:25:48 +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) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4BwqVv6s71z12W; Tue, 22 Sep 2020 18:25:43 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4BwqVv5XR4z30Wm; Tue, 22 Sep 2020 18:25:43 +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) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4BwqVs70Ncz2xhT for ; Tue, 22 Sep 2020 18:25:41 +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 4BwqVs4q1VzvR; Tue, 22 Sep 2020 18:25:41 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1600799141; 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: in-reply-to:in-reply-to:references:references; bh=EQn/sK1o1h384qETYYTR8xEZ/Qib5YgobEJbYAMy57g=; b=Q2AvHrRAglq2iU0wq3jIbV8I+gEjkrmHyauyDXu8kEcSWG5/GdV0BXmFk4ea+Q5PRAs3Ok IFhMDVNizHNRY6Ag== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1600799141; 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: in-reply-to:in-reply-to:references:references; bh=EQn/sK1o1h384qETYYTR8xEZ/Qib5YgobEJbYAMy57g=; b=F8eXwybifauLhNatHSKMJMYedFhU4FKcPoIq+U4idZNT0U7TipD05zqY5ns40kAUt1d5gh LXjjyXSmTPamo3RUOwYleyGug4o0DiDwo1YQIenv79taGmi2NVU4G5Z2um+GrolMhtxm6L nEKFu7UIesu4RU6rBOh8eSKDqd3XqejpkyZ14ixObKZjMkjtVRqZrXyLWl83zxK4sZSmDM Z9MFKh+KVwZZBVDwSES1YL3Lst7q6SEYiTsrj3elFrE47IS6SaAkID2ESFuCixd5VBxMLX aPbHmpS9CbU03mIupkkiFB7spQZTmdezpx9VOaCZyjPM3kgZPYEs5Hu3IWCgjw== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 02/11] location-functions.pl: Refactor get_full_country_name() function to use the Location module. Date: Tue, 22 Sep 2020 20:25:00 +0200 Message-Id: <20200922182509.18643-2-stefan.schantl@ipfire.org> In-Reply-To: <20200922182509.18643-1-stefan.schantl@ipfire.org> References: <20200922182509.18643-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass smtp.mailfrom=stefan.schantl@ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 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" Signed-off-by: Stefan Schantl --- config/cfgroot/location-functions.pl | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/config/cfgroot/location-functions.pl b/config/cfgroot/location-functions.pl index a94d5909e..c8ccd94c2 100644 --- a/config/cfgroot/location-functions.pl +++ b/config/cfgroot/location-functions.pl @@ -24,18 +24,13 @@ package Location::Functions; use Location; -use Locale::Codes::Country; # Hash which contains country codes and their names which are special or not # part of ISO 3166-1. my %not_iso_3166_location = ( - "a1" => "Anonymous Proxy", - "a2" => "Satellite Provider", - "a3" => "Worldwide Anycast Instance", - "an" => "Netherlands Antilles", - "ap" => "Asia/Pacific Region", - "eu" => "Europe", - "fx" => "France, Metropolitan" + "A1" => "Anonymous Proxy", + "A2" => "Satellite Provider", + "A3" => "Worldwide Anycast Instance", ); # Array which contains special country codes. @@ -152,17 +147,19 @@ sub get_full_country_name($) { # Remove whitespaces. chomp($input); + # Convert input into upper case format. + my $code = uc($input); - # Convert input into lower case format. - my $code = lc($input); - - # Handle country codes which are not in the list. + # Handle country codes which are special or not part of the list. if ($not_iso_3166_location{$code}) { # Grab location name from hash. $name = $not_iso_3166_location{$code}; } else { - # Use perl built-in module to get the country code. - $name = &Locale::Codes::Country::code2country($code); + # Init libloc database connection. + my $db_handle = &init(); + + # Get the country name by using the location module. + $name = &Location::get_country_name($db_handle, $code); } return $name; From patchwork Tue Sep 22 18:25:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 3478 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 4BwqVz74s3z3wbW for ; Tue, 22 Sep 2020 18:25:47 +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) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4BwqVw1RDfz12c; Tue, 22 Sep 2020 18:25:44 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4BwqVv6G1Xz30Wv; Tue, 22 Sep 2020 18:25:43 +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) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4BwqVt2Yjpz2xhT for ; Tue, 22 Sep 2020 18:25:42 +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 4BwqVt0Pjsz107; Tue, 22 Sep 2020 18:25:41 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1600799142; 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: in-reply-to:in-reply-to:references:references; bh=GJ6aZgO/kqcQ+Bz+1RNbMwlvT7UDwI4SPvKNNUdi5po=; b=AEZHwm6p7YZhoRwQ2GUshoecZJlXTp7wR7U0Z4MjkaRuAS3s/IjYaskxhBz0OOaWmPnIf1 IzMGNX3YbqFoEkBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1600799142; 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: in-reply-to:in-reply-to:references:references; bh=GJ6aZgO/kqcQ+Bz+1RNbMwlvT7UDwI4SPvKNNUdi5po=; b=uFMBxkvYbBbVbK27Q55/aEMAO0hwgXZdVHNlKkkUZzlkgyjBgn55XD7zIFU+GVn6nlMOqz 2gNWplzf0hzOSoRubHSxCzNMPZwjPtotIze4TQlk76SjJ4c1BONN/CyXtw0MXeRUYLK1rf /KEzkcti0qilHFskTvwnJH/gUF0GX4LVOu+tCi+vfk7lpqS5x0Pg7lO9xnnQ3F6OFbjYfO NPKJl/p6ufKFHs9OfBEjdn/d+/ZLQvFzbQGtRVzwmXQjtg5emCKLfYik5qrOkxicSaWIUQ lB9tLDqnQu2E9N5nE7Dxn9bcIL7Mm5WqO0f/IxsOLs6PP1lQktPVADtG8q16Ow== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 03/11] location-functions.pl: Add address_has_flag() function. Date: Tue, 22 Sep 2020 20:25:01 +0200 Message-Id: <20200922182509.18643-3-stefan.schantl@ipfire.org> In-Reply-To: <20200922182509.18643-1-stefan.schantl@ipfire.org> References: <20200922182509.18643-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass smtp.mailfrom=stefan.schantl@ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 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" This function can be used to check if a given address has one of the known flags like "Anonymous Proxy". If this is true, the mapped special country code will be returned. Signed-off-by: Stefan Schantl --- config/cfgroot/location-functions.pl | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/config/cfgroot/location-functions.pl b/config/cfgroot/location-functions.pl index c8ccd94c2..b0b8cd086 100644 --- a/config/cfgroot/location-functions.pl +++ b/config/cfgroot/location-functions.pl @@ -33,6 +33,13 @@ my %not_iso_3166_location = ( "A3" => "Worldwide Anycast Instance", ); +# Hash which contains possible network flags and their mapped location codes. +my %network_flags = ( + "LOC_NETWORK_FLAG_ANONYMOUS_PROXY" => "A1", + "LOC_NETWORK_FLAG_SATELLITE_PROVIDER" => "A2", + "LOC_NETWORK_FLAG_ANYCAST" => "A3", +); + # Array which contains special country codes. my @special_locations = ( "A1", "A2", "A3" ); @@ -183,4 +190,26 @@ sub get_locations() { return @sorted_locations; } +# Function to check if a given address has a special flag. +sub address_has_flag($) { + my ($address) = @_; + + # Init libloc database handle. + my $db_handle = &init(); + + # Loop through the hash of possible network flags. + foreach my $flag (keys(%network_flags)) { + # Check if the address has the current flag. + if (&Location::lookup_network_has_flag($db_handle, $address, $flag)) { + # The given address has the requested flag. + # + # Grab the mapped location code for this flag. + $mapped_code = $network_flags{$flag}; + + # Return the code. + return $mapped_code; + } + } +} + 1; From patchwork Tue Sep 22 18:25:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 3481 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) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4BwqW11Dwsz3wbW for ; Tue, 22 Sep 2020 18:25:49 +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) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4BwqVy0bktz11Y; Tue, 22 Sep 2020 18:25:46 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4BwqVx6yf0z30WJ; Tue, 22 Sep 2020 18:25:45 +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) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4BwqVt5QWdz30Wf for ; Tue, 22 Sep 2020 18:25:42 +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 4BwqVt36GXz11Q; Tue, 22 Sep 2020 18:25:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1600799142; 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: in-reply-to:in-reply-to:references:references; bh=JgIMwmzpjbVHB/1N2x+RneU0QeRJhyLO/u912vFltHk=; b=W41f3/OpI3irioaWR2d+Elg7yMvRiaOELdI0/0xuGQLDGQ6RdI/OkBsGhzUz8bexEi9td6 xqPsGyEyR32VVyYcnH5IR8kL02tTJtZTlVzdFkf1QN+6Eh1BzdkDX4i+BpLAf/+RbGfHHb 2Yf/K5Z4dthVwzzmEJ/xUh99AKYq7zs+uE0dlkf+TOaeRsROorR5BrwjsYZTGAgM+psHTm U2b9Zo/Jkwzwo61pT9sbe6u03SYla0bThNrtPOA15IqpxLaSbglyThwiRnERKzyUa0gQGO KejR2Wkih3sxIojumwzYefIty5gQUIKst6n21zNmPH6s0Mjfj8at86YTHK0FMg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1600799142; 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: in-reply-to:in-reply-to:references:references; bh=JgIMwmzpjbVHB/1N2x+RneU0QeRJhyLO/u912vFltHk=; b=Jpxica5HqG3SJK5yTHEr0ivmKmZX1Pnk1lu03R1JotFj6HjZApdZxMfpz+Gsa1k0p70J3B WvMalqFfSYv6UhDw== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 04/11] country.cgi: Use own location-functions. Date: Tue, 22 Sep 2020 20:25:02 +0200 Message-Id: <20200922182509.18643-4-stefan.schantl@ipfire.org> In-Reply-To: <20200922182509.18643-1-stefan.schantl@ipfire.org> References: <20200922182509.18643-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass smtp.mailfrom=stefan.schantl@ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 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" Signed-off-by: Stefan Schantl --- html/cgi-bin/country.cgi | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/html/cgi-bin/country.cgi b/html/cgi-bin/country.cgi index a1cf24347..b519d89b3 100644 --- a/html/cgi-bin/country.cgi +++ b/html/cgi-bin/country.cgi @@ -21,8 +21,6 @@ use strict; -use Locale::Codes::Country; - my $col; my $lines = '1'; my $lines2 = ''; @@ -32,6 +30,8 @@ require "${General::swroot}/location-functions.pl"; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +require "${General::swroot}/location-functions.pl"; + &Header::showhttpheaders(); &Header::openpage($Lang::tr{'countries'}, 1, ''); @@ -52,8 +52,11 @@ print< END +# Init libloc database connection. +my $db_handle = &Location::Functions::init(); + # Get a list of all supported country codes. -my @countries = Locale::Codes::Country::all_country_codes(); +my @countries = &Location::database_countries($db_handle); # Loop through whole country list. foreach my $country (@countries) { From patchwork Tue Sep 22 18:25:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 3482 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) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4BwqW12JbRz3x61 for ; Tue, 22 Sep 2020 18:25:49 +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) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4BwqVy1QSFz12m; Tue, 22 Sep 2020 18:25:46 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4BwqVy0Zcdz3072; Tue, 22 Sep 2020 18:25:46 +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) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4BwqVv139Vz3072 for ; Tue, 22 Sep 2020 18:25:43 +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 4BwqVt5sjnz11Y; Tue, 22 Sep 2020 18:25:42 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1600799143; 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: in-reply-to:in-reply-to:references:references; bh=8aPwae/chgZu6rVfP5e28c9Zexz3R4JYRLvW9+7cUCM=; b=TrISjTdkV3sDAbiKXdws8GDz7Qebvv/4AqModufolO6H2CWAm21xPko0T71o7VsL/GA03r HTZD+oFtcAb9YsCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1600799143; 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: in-reply-to:in-reply-to:references:references; bh=8aPwae/chgZu6rVfP5e28c9Zexz3R4JYRLvW9+7cUCM=; b=AwcMqszdPJgGI7i+hmfhj7JiycUnmeEPMWet7J1mnybfVFw6wFVKuxzvVSqvL/O33MypN/ 6I2gcp2B4uyAKQCLrI09D6x/mmQK+Lz6umeasb+0WRLZ5TodTgusbKmgibRklRdIawCdBB 3I4a0pRR3sUAC2PCNS3SKD/KaQLO12P0DKp6EWM1GWxp0SlncRibCCr4aqzFnckn5MyXeI ZFNyYqZOVMfN9hOvfcpe4e2VcFg8iV0LbGwpg10v7gZ4hzo19TuRdKVAkMFXI9cdr/sOBL GeiK3fvSdsMVjWMTiWzNTXRjPwwJ46QisXFBUOpeHNZQ59xusPE7FAUaybcZSw== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 05/11] tor.cgi: Use own location functions. Date: Tue, 22 Sep 2020 20:25:03 +0200 Message-Id: <20200922182509.18643-5-stefan.schantl@ipfire.org> In-Reply-To: <20200922182509.18643-1-stefan.schantl@ipfire.org> References: <20200922182509.18643-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass smtp.mailfrom=stefan.schantl@ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 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" Signed-off-by: Stefan Schantl --- html/cgi-bin/tor.cgi | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/html/cgi-bin/tor.cgi b/html/cgi-bin/tor.cgi index c9416be01..28dec6cf0 100644 --- a/html/cgi-bin/tor.cgi +++ b/html/cgi-bin/tor.cgi @@ -20,7 +20,6 @@ ############################################################################### use strict; -use Locale::Codes::Country; # enable only the following on debugging purpose #use warnings; @@ -31,6 +30,9 @@ require "${General::swroot}/location-functions.pl"; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +# Init libloc database connection. +my $db_handle = &Location::Functions::init(); + #workaround to suppress a warning when a variable is used only once my @dummy = ( ${Header::colouryellow} ); undef (@dummy); @@ -321,10 +323,14 @@ END END - my @country_names = Locale::Codes::Country::all_country_names(); - foreach my $country_name (sort @country_names) { - my $country_code = Locale::Codes::Country::country2code($country_name); + my @country_codes = &Location::database_countries(); + foreach my $country_code (@country_codes) { + # Convert country code into upper case format. $country_code = uc($country_code); + + # Get country name. + my $country_name = &Location::Functions::get_country_name($country_code); + print "