public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@mandelbit.com>
To: development@lists.ipfire.org
Cc: Antonio Quartulli <antonio@mandelbit.com>
Subject: [PATCH 4/4] http-client-functions.pl: Use the address ddns publishes for the sync check
Date: Tue,  1 Dec 2026 15:31:53 +0100	[thread overview]
Message-ID: <20261201143155.1798388-5-antonio@mandelbit.com> (raw)
In-Reply-To: <20261201143155.1798388-1-antonio@mandelbit.com>

GetDyndnsRedIP() only fetched the public address if "Fetch the public
IP" was selected and RED was in RFC1918 or the shared address space.
ddns uses it whenever fetching is selected, and when RED can't be
reached from the Internet, e.g. in 169.254.0.0/16, so the web interface
showed those hosts as out of sync. With RED behind a router, the page
now fetches the address like ddns does.

Bug: #14766
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
 config/cfgroot/http-client-functions.pl | 26 ++++++++++---------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/config/cfgroot/http-client-functions.pl b/config/cfgroot/http-client-functions.pl
index aefad7639..6a0a0fa4d 100644
--- a/config/cfgroot/http-client-functions.pl
+++ b/config/cfgroot/http-client-functions.pl
@@ -313,7 +313,7 @@ sub FetchPublicIp {
 }
 
 #
-# This sub returns the red IP used to compare in DyndnsServiceSync
+# This sub returns the address that ddns publishes, to compare in DyndnsServiceSync
 #
 sub GetDyndnsRedIP {
 	my %settings;
@@ -322,21 +322,15 @@ sub GetDyndnsRedIP {
 	&General::readhash("${General::swroot}/ddns/settings", \%settings);
 
 	# Try to grab the address from the local-ipaddress file.
-	my $ip = &Network::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 (&Network::ip_address_in_network($ip, "10.0.0.0/255.0.0.0") ||
-		&Network::ip_address_in_network($ip, "172.16.0.0/255.240.0.0") ||
-		&Network::ip_address_in_network($ip, "192.168.0.0/255.255.0.0") ||
-		&Network::ip_address_in_network($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 = (&Network::check_ip_address ($RealIP) ?  $RealIP : 'unavailable');
-		}
+	my $ip = &Network::grab_address_from_file("${General::swroot}/red/local-ipaddress");
+
+	# Like ddns, use the public address if asked to, or if RED is unknown or
+	# can't be reached from the Internet
+	if ($settings{'BEHINDROUTER'} eq 'FETCH_IP' || !&Network::ip_address_is_global($ip)) {
+		my $RealIP = &FetchPublicIp;
+
+		# Check if the grabbed address is valid.
+		$ip = (&Network::check_ip_address ($RealIP) ?  $RealIP : 'unavailable');
 	}
 
 	return $ip;
-- 
2.56.1



      parent reply	other threads:[~2026-12-01 14:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 14:31 [PATCH 0/4] Use the address ddns publishes in the DDNS sync check (#14766) Antonio Quartulli
2026-12-01 14:31 ` [PATCH 1/4] network-functions.pl: Add ip_address_is_global() Antonio Quartulli
2026-12-01 14:31 ` [PATCH 2/4] wio.cgi: Get the address of the DDNS hosts only once Antonio Quartulli
2026-12-01 14:31 ` [PATCH 3/4] ddns.cgi: Get the address of the DDNS hosts only when needed Antonio Quartulli
2026-12-01 14:31 ` Antonio Quartulli [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201143155.1798388-5-antonio@mandelbit.com \
    --to=antonio@mandelbit.com \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox