[3/4] ddns.cgi: Get the address of the DDNS hosts only when needed
Commit Message
GetDyndnsRedIP() can fetch the public address from a server, which was
done on every page load, even without any enabled host.
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
html/cgi-bin/ddns.cgi | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
@@ -445,8 +445,9 @@ print $form->render();
-e $datafile or die "Unable to open $datafile.";
@current = &General::read_file($datafile, { keep_newlines => 1 });
-# Get IP address of the red interface.
-my $ip = &HTTPClient::GetDyndnsRedIP();
+# The address of the hosts, which may have to be fetched from a server: only
+# get it when needed
+my $ip;
my $id = 0;
my $toggle_enabled;
@@ -484,6 +485,7 @@ if (@current) {
$fqdn =~ s/^[\*\@]\.//;
if (&Network::check_fqdn($fqdn)) {
+ $ip //= &HTTPClient::GetDyndnsRedIP();
$sync = (&HTTPClient::DyndnsServiceSync ($ip,$temp[1], $temp[2]) ? "has-text-success" : "has-text-danger");
}