From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4ZKjN828C6z333w for ; Sat, 22 Mar 2025 15:07:20 +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 (secp384r1) client-signature RSA-PSS (4096 bits)) (Client CN "mail01.haj.ipfire.org", Issuer "R10" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4ZKjN45K3Zz333d for ; Sat, 22 Mar 2025 15:07:16 +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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4ZKjN41CH8z8v1; Sat, 22 Mar 2025 15:07:16 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1742656036; 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=IisB0D8FTf25dezAOvb68ggL0CzMBIT5H1U2eTJm9pY=; b=cm/o8cv5mQeI1JE2kdw5wGSPG04WunsmWwuCcYIqMMtyMo69XxhcJpRabB1kVqARIc+GTU 8OWvZo+zbLlhlGCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1742656036; 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=IisB0D8FTf25dezAOvb68ggL0CzMBIT5H1U2eTJm9pY=; b=M5A8Gvvm+GIWCr2ENF+x/DWEdmRgeJ0GR75L/W01hDkTnzg3e4IkgvnJzOHrNWSmwIY4Un xui9PYusri0kDWqJsVirKRtiaWmOZhBkX+d35NppQOj+9DDbGdDZsxQCbWtKOBZZjKEapm hg9f/6QcoXyo540+F8BfG2SUrF1dFWpfJSrgE7ldj7SefeT8wzUkTyFqrz+3htZ7HcZUHs kZ0WA2ygm+UF53O51t5mlRsp34+ORC9kyCyWQ9GOPqLEND0nTmTHVsFPXpcqKs0U7PLaTW VQJtam2zR4EcBLlCrNRrN6YinLvr6MO+Lx6j6fn8gsdbbVCfz+YuLHKWw6OfNg== From: Stefan Schantl To: development@lists.ipfire.org Cc: Stefan Schantl Subject: [PATCH 2/3] general-functions.pl: Use new downloader for FetchPublicIp function. Date: Sat, 22 Mar 2025 15:57:23 +0100 Message-ID: <20250322145724.4593-2-stefan.schantl@ipfire.org> In-Reply-To: <20250322145724.4593-1-stefan.schantl@ipfire.org> References: <20250322145724.4593-1-stefan.schantl@ipfire.org> Precedence: list List-Id: List-Subscribe: , List-Unsubscribe: , List-Post: List-Help: Sender: Mail-Followup-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This helps to drop the Net::SSLeay module and to remove a lot of legacy code. Signed-off-by: Stefan Schantl --- config/cfgroot/general-functions.pl | 32 +++++++++++++---------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/config/cfgroot/general-functions.pl b/config/cfgroot/general-functions.pl index cb8df69c6..a132cf315 100644 --- a/config/cfgroot/general-functions.pl +++ b/config/cfgroot/general-functions.pl @@ -17,7 +17,6 @@ package General; use strict; use Socket; use IO::Socket; -use Net::SSLeay; use Net::IPv4Addr qw(:all); # Load module to move files. @@ -979,23 +978,20 @@ sub findhasharraykey { } sub FetchPublicIp { - my %proxysettings; - &General::readhash("${General::swroot}/proxy/settings", \%proxysettings); - if ($_=$proxysettings{'UPSTREAM_PROXY'}) { - my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/); - Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} ); - } - my $user_agent = &MakeUserAgent(); - my ($out, $response) = Net::SSLeay::get_http( 'checkip4.dns.lightningwirelabs.com', - 80, - "/", - Net::SSLeay::make_headers('User-Agent' => $user_agent ) - ); - if ($response =~ m%HTTP/1\.. 200 OK%) { - $out =~ /Your IP address is: (\d+.\d+.\d+.\d+)/; - return $1; - } - return ''; + # URL to grab the public IP. + my $url = "https://checkip4.dns.lightningwirelabs.com"; + + # Call downloader to fetch the public IP. + my $response = &downloader("URL" => $url); + + # Omit the address from the resonse message. + if ($response =~ /Your IP address is: (\d+.\d+.\d+.\d+)/) { + # Return the address. + return $1; + } + + # Unable to grab the address - Return nothing. + return; } # -- 2.47.2