From patchwork Tue Nov 3 11:50:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Peter_M=C3=BCller?= X-Patchwork-Id: 3629 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 4CQSlZ5dY0z3why for ; Tue, 3 Nov 2020 11:50:34 +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 4CQSlP24xzzpR; Tue, 3 Nov 2020 11:50:25 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4CQSlP0DkFz2yXb; Tue, 3 Nov 2020 11:50:25 +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 4CQSlM5cJvz2xZH for ; Tue, 3 Nov 2020 11:50:23 +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) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4CQSlL35Dgz8F for ; Tue, 3 Nov 2020 11:50:22 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1604404223; h=from:from: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; bh=PL4SX2jk8QJBLVskTgmRtor684HuzDiqYmuiNNHfPoE=; b=M0fF4d3g9i37oLWoT5vl9ew6STJ5dOQGAfESprWnh9LwfNRC6u2t2zbr8r+2JXYextDD38 n2Mzr4NW/2vCJ5Cw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1604404223; h=from:from: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; bh=PL4SX2jk8QJBLVskTgmRtor684HuzDiqYmuiNNHfPoE=; b=IqtuYpe1p4HuTes5NA2A85RUfSYi8Y9fJgdnWz0aHbtrUs1ZqPFoeZ0UYMTLephM9U3s7q 9QpzL+57Np5jv52t2NKYgydqJhNAy0ecu9RaA0+1jefSqcxNngt/jiKUluSSLaCOGagWr6 dQq8bpmvCn3udoDX6TcGkRnQ6aFjXKoMo8w7KGt8XdQ654BiavhIvLXFX/PoshLaY4D97C As1PpDYzdWMTphanfloco+2kngGXM+1uV/Me9mJGlrtN8BXGHZHbY81HiBmrKX95tJVGUa 9wmrhetj684MohvaNG0vI49s+y18yIU/ILfchCL0dfOYTZfhVhuWr6jUtjgzSA== To: "IPFire: Development-List" From: =?utf-8?q?Peter_M=C3=BCller?= Subject: [PATCH] tor.cgi: look up Tor relay country codes using libloc Message-ID: <521c62a4-a948-f340-1642-813f3e811374@ipfire.org> Date: Tue, 3 Nov 2020 12:50:18 +0100 MIME-Version: 1.0 Content-Language: en-US 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" Tor provides a function to resolve a relay's IP address into a country code by taking advantage of a (heavily outdated) GeoIP database shipped with it. We should consequently use libloc for doing this, since it can be confusing if those results differ from active connections in the connection tracking CGI (where we _use_ libloc) and such tasks are why we invented libloc in the first place. :-) Signed-off-by: Peter Müller --- html/cgi-bin/tor.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/cgi-bin/tor.cgi b/html/cgi-bin/tor.cgi index 7447bd791..14bfcfe90 100644 --- a/html/cgi-bin/tor.cgi +++ b/html/cgi-bin/tor.cgi @@ -912,7 +912,7 @@ sub TorNodeDescription() { $node->{'address'} = $3; $node->{'port'} = $4; - my $country_code = &TorGetInfo($tor, "ip-to-country/$node->{'address'}"); + my $country_code = &Location::Functions::lookup_country_code($db_handle, $node->{'address'}); $node->{'country_code'} = $country_code; # Flags