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 4ZLFMv0nNxz331L for ; Sun, 23 Mar 2025 12:08:59 +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 4ZLFMq3nf0z32vy for ; Sun, 23 Mar 2025 12:08:55 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4ZLFMq0nhMz66; Sun, 23 Mar 2025 12:08:55 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1742731735; 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: in-reply-to:in-reply-to:references:references; bh=BPaYW7uOJC8rvRJtB/xBCiDizKcekpjV871cBU+BEZU=; b=bfxkzCOdsXRNi6CVHg2lULSjPWTiHvA6iq2GayMU81f52dY5p+ywoRMI57m/fMJVMz2Jmf 1sKSLrjiebt+7rCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1742731735; 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: in-reply-to:in-reply-to:references:references; bh=BPaYW7uOJC8rvRJtB/xBCiDizKcekpjV871cBU+BEZU=; b=st/gBBSefZgz3kYjAIUNDv6b63Gth25DWev/4ZHYS3u/3NjlxJI27in78AIaGaN8DSiXhS Y9TI67ohM3A4NFYKkB0mRfQpK21ahUxtadS7MGoZToCP1lsI9jAKqLVKcszcoWdW4Af9Hv S3C31ND+QJth6Jmi17PH8HfbftE5kbuQnySBUPD/hA1Fb7hjm3c1oahBH6V+AkjeVK4F4V M1VzIGnHUQ0NrmrXcahtLAYGrIeNG25udhV2xAFwVoR9xMisAA1CQhMfu8/BBvTqUAqqV0 BV6KXWiPNcEKNLW4kXD0HLc2rqNEvsDkUAjSUWQ4iQWw1Jcu5kMF3paJzpB6Cw== Content-Type: text/plain; charset=us-ascii Precedence: list List-Id: List-Subscribe: , List-Unsubscribe: , List-Post: List-Help: Sender: Mail-Followup-To: Mime-Version: 1.0 Subject: Re: [PATCH 2/3] general-functions.pl: Use new downloader for FetchPublicIp function. From: Michael Tremer In-Reply-To: <20250322145724.4593-2-stefan.schantl@ipfire.org> Date: Sun, 23 Mar 2025 12:08:54 +0000 Cc: development@lists.ipfire.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20250322145724.4593-1-stefan.schantl@ipfire.org> <20250322145724.4593-2-stefan.schantl@ipfire.org> To: Stefan Schantl This is much better and cleaner code than before. Well done! > On 22 Mar 2025, at 14:57, Stefan Schantl = wrote: >=20 > This helps to drop the Net::SSLeay module and to remove a lot of = legacy > code. >=20 > Signed-off-by: Stefan Schantl > --- > config/cfgroot/general-functions.pl | 32 +++++++++++++---------------- > 1 file changed, 14 insertions(+), 18 deletions(-) >=20 > 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); >=20 > # Load module to move files. > @@ -979,23 +978,20 @@ sub findhasharraykey { > } >=20 > sub FetchPublicIp { > - my %proxysettings; > - &General::readhash("${General::swroot}/proxy/settings", = \%proxysettings); > - if ($_=3D$proxysettings{'UPSTREAM_PROXY'}) { > - my ($peer, $peerport) =3D (/^(?:[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'},$pr= oxysettings{'UPSTREAM_PASSWORD'} ); > - } > - my $user_agent =3D &MakeUserAgent(); > - my ($out, $response) =3D Net::SSLeay::get_http( = 'checkip4.dns.lightningwirelabs.com', > - 80, > - "/", > - Net::SSLeay::make_headers('User-Agent' =3D> $user_agent ) > - ); > - if ($response =3D~ m%HTTP/1\.. 200 OK%) { > - $out =3D~ /Your IP address is: (\d+.\d+.\d+.\d+)/; > - return $1; > - } > - return ''; > + # URL to grab the public IP. > + my $url =3D "https://checkip4.dns.lightningwirelabs.com"; > + > + # Call downloader to fetch the public IP. > + my $response =3D &downloader("URL" =3D> $url); > + > + # Omit the address from the resonse message. > + if ($response =3D~ /Your IP address is: (\d+.\d+.\d+.\d+)/) { > + # Return the address. > + return $1; > + } > + > + # Unable to grab the address - Return nothing. > + return; > } >=20 > # > --=20 > 2.47.2 >=20 >=20