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 4ZfC182CsXz338F for ; Fri, 18 Apr 2025 11:18:04 +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 4ZfC145fnTz30Zp for ; Fri, 18 Apr 2025 11:18:00 +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 4ZfC131F2yz35D; Fri, 18 Apr 2025 11:17:59 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1744975079; 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=37j1i0ue6ZPaWOloxG+gTqRx+OwRTPyBfTVUAGj0w2U=; b=2irh7Iq9WlwKaZ/hSH9u49oE5Jzy1ODWVFPnAhJnbtqo+GRGbtQTe5+ff3AkXDAPg35bnr cfGWMT1DsqNZ/5Cw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1744975079; 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=37j1i0ue6ZPaWOloxG+gTqRx+OwRTPyBfTVUAGj0w2U=; b=H5acJBBDj3/BSen1jlplhjLiTmphjJRdNM4KguMl3z7sx/uSPUo7+BQA/L5EfRXxbXWF+s p9r93TTuL0irk3d+xLlMxQyxKZw6LuNzSyneO9rycHqY/nJZsQ/nPHYqy6aMiQYpONs2LM k/DI1c94gh/RWOMaYcPecgUww0PB8DPraFro1dPZmuoTP4caPHYALRwkL4k0hqNnh5wMHG twFU+CjXq2EZMqetCpBoP8uFyw6oyEDIOxaHSXotkiQ/rEthjosWpMR4vYiws1LFsqg2NB MJu00hgqVwaG610CVuFadkBDmLUKp0yr7fPZ/9XS/vfxOXcbUnSeznYKLrqj3w== From: Stefan Schantl To: development@lists.ipfire.org Cc: Stefan Schantl Subject: [PATCHv2 4/7] Move GetDyndnsRedIP from general-functions.pl to http-client-functions.pl Date: Fri, 18 Apr 2025 12:54:43 +0200 Message-ID: <20250418110741.7756-5-stefan.schantl@ipfire.org> In-Reply-To: <20250418110741.7756-1-stefan.schantl@ipfire.org> References: <20250418110741.7756-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 function depends on the previously FetchPublicIp function and so also has to be moved. Signed-off-by: Stefan Schantl --- config/cfgroot/general-functions.pl | 25 --------------------- config/cfgroot/http-client-functions.pl | 30 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/config/cfgroot/general-functions.pl b/config/cfgroot/general-functions.pl index 861f95dec..bbd0f9839 100644 --- a/config/cfgroot/general-functions.pl +++ b/config/cfgroot/general-functions.pl @@ -998,31 +998,6 @@ sub DyndnsServiceSync ($;$;$) { } return 0; } -# -# This sub returns the red IP used to compare in DyndnsServiceSync -# -sub GetDyndnsRedIP { - my %settings; - &General::readhash("${General::swroot}/ddns/settings", \%settings); - - open(IP, "${General::swroot}/red/local-ipaddress") or return 'unavailable'; - my $ip = ; - close(IP); - chomp $ip; - - # 100.64.0.0/10 is reserved for dual-stack lite (http://tools.ietf.org/html/rfc6598). - if (&General::IpInSubnet ($ip,'10.0.0.0','255.0.0.0') || - &General::IpInSubnet ($ip,'172.16.0.0.','255.240.0.0') || - &General::IpInSubnet ($ip,'192.168.0.0','255.255.0.0') || - &General::IpInSubnet ($ip,'100.64.0.0', '255.192.0.0')) - { - if ($settings{'BEHINDROUTER'} eq 'FETCH_IP') { - my $RealIP = &General::FetchPublicIp; - $ip = (&General::validip ($RealIP) ? $RealIP : 'unavailable'); - } - } - return $ip; -} # Translate ICMP code to text # ref: http://www.iana.org/assignments/icmp-parameters diff --git a/config/cfgroot/http-client-functions.pl b/config/cfgroot/http-client-functions.pl index bfb9fdd20..f1f7de309 100644 --- a/config/cfgroot/http-client-functions.pl +++ b/config/cfgroot/http-client-functions.pl @@ -307,4 +307,34 @@ sub FetchPublicIp { return; } +# +# This sub returns the red IP used to compare in DyndnsServiceSync +# +sub GetDyndnsRedIP { + my %settings; + + # Read-in ddns settings. + &General::readhash("${General::swroot}/ddns/settings", \%settings); + + # Try to grab the address from the local-ipaddress file. + my $ip = &General::grab_address_from_file("${General::swroot}/red/local-ipaddress") or return 'unavailable'; + + # 100.64.0.0/10 is reserved for dual-stack lite (http://tools.ietf.org/html/rfc6598). + if (&General::IpInSubnet ($ip,'10.0.0.0','255.0.0.0') || + &General::IpInSubnet ($ip,'172.16.0.0.','255.240.0.0') || + &General::IpInSubnet ($ip,'192.168.0.0','255.255.0.0') || + &General::IpInSubnet ($ip,'100.64.0.0', '255.192.0.0')) + { + if ($settings{'BEHINDROUTER'} eq 'FETCH_IP') { + # Call function to omit the real address. + my $RealIP = &FetchPublicIp; + + # Check if the grabbed address is valid. + $ip = (&General::validip ($RealIP) ? $RealIP : 'unavailable'); + } + } + + return $ip; +} + 1; -- 2.47.2