[2/4] wio.cgi: Get the address of the DDNS hosts only once
Commit Message
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(-)
@@ -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>");