[2/4] wio.cgi: Get the address of the DDNS hosts only once

Message ID 20261201143155.1798388-3-antonio@mandelbit.com
State Staged
Commit ba03ea60817f28fc31ee9fe33690f3dcc130b87a
Headers
Series Use the address ddns publishes in the DDNS sync check (#14766) |

Commit Message

Antonio Quartulli 1 Dec 2026, 2:31 p.m. UTC
GetDyndnsRedIP() can fetch the public address from a server, which was
done for each enabled host.

Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
 html/cgi-bin/wio.cgi | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Patch

diff --git a/html/cgi-bin/wio.cgi b/html/cgi-bin/wio.cgi
index 35e8ff041..8a229c92b 100755
--- a/html/cgi-bin/wio.cgi
+++ b/html/cgi-bin/wio.cgi
@@ -1030,6 +1030,9 @@  my @dyndnsnames = ();
 if ( -s "$dyndnsconfig" ) {
 	@ddns = &General::read_file($dyndnsconfig);
 
+	# May have to be fetched from a server: only do it once
+	my $ddnsip;
+
 	foreach (@ddns) {
 		chomp;
 		@temp = split (/\,/, $_);
@@ -1037,7 +1040,8 @@  if ( -s "$dyndnsconfig" ) {
 		my $class = "has-text-info";
 
 		if ( $temp[7] eq "on" ) {
-			$class = ( &HTTPClient::DyndnsServiceSync (&HTTPClient::GetDyndnsRedIP,$temp[1],$temp[2]) ? "has-text-success" : "has-text-danger" );
+			$ddnsip //= &HTTPClient::GetDyndnsRedIP();
+			$class = ( &HTTPClient::DyndnsServiceSync ($ddnsip,$temp[1],$temp[2]) ? "has-text-success" : "has-text-danger" );
 		}
 
 		push(@dyndnsnames, "<span class='$class'>@{[ &Header::escape($temp[1]) ]}.@{[ &Header::escape($temp[2]) ]}</span>");