From 4851bc81f33058d814028ab91f4badf46739f373 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Sat, 26 Jul 2014 18:26:37 +0200 Subject: [PATCH] ddns.cgi: Support hostname details without seperating dots. To keep compatiblity with the settings file of the old DDNS update script (setddns.pl) we keept the storrage of the hostname information in two parts (hostname and domain) and connected both with a dot to get a valid FQDN again. OpenDNS and may some other providers do not use a dotted format for this information, so one of these two values were empty. We now can handle such cases in a right way. --- html/cgi-bin/ddns.cgi | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/html/cgi-bin/ddns.cgi b/html/cgi-bin/ddns.cgi index 3de8886dd1..55841b2b99 100644 --- a/html/cgi-bin/ddns.cgi +++ b/html/cgi-bin/ddns.cgi @@ -293,8 +293,17 @@ if ($settings{'ACTION'} eq $Lang::tr{'edit'}) { # Splitt lines (splitting element is a single ",") and save values into temp array. @temp = split(/\,/,$line); + # Handle hostname details. Only connect the values with a dott if both are available. + my $hostname; + + if (($temp[1]) && ($temp[2])) { + $hostname = "$temp[1].$temp[2]"; + } else { + $hostname = "$temp[1]"; + } + $settings{'SERVICE'} = $temp[0]; - $settings{'HOSTNAME'} = "$temp[1].$temp[2]"; + $settings{'HOSTNAME'} = $hostname; $settings{'PROXY'} = $temp[3]; $settings{'WILDCARDS'} = $temp[4]; $settings{'LOGIN'} = $temp[5]; @@ -531,11 +540,20 @@ END $col="bgcolor='$color{'color22'}'"; } + # Handle hostname details. Only connect the values with a dott if both are available. + my $hostname=""; + + if (($temp[1]) && ($temp[2])) { + $hostname="$temp[1].$temp[2]"; + } else { + $hostname="$temp[1]"; + } + # The following HTML Code still is part of the loop. print < $temp[0] - $sync$temp[1].$sync$temp[2] + $sync$hostname
@@ -637,7 +655,13 @@ sub GenerateDDNSConfigFile { # Skip disabled entries. next unless ($enabled eq "on"); - print FILE "[$hostname.$domain]\n"; + # Handle hostname details. Only connect the values with a dott if both are available. + if (($hostname) && ($domain)) { + print FILE "[$hostname.$domain]\n"; + } else { + print FILE "[$hostname]\n"; + } + print FILE "provider = $provider\n"; my $use_token = 0; -- 2.39.2