require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
-# Hook to regenerate the configuration files, if cgi got called from command line.
-if ($ENV{"REMOTE_ADDR"} eq "") {
- &GenerateDDNSConfigFile();
- exit(0);
-}
-
#workaround to suppress a warning when a variable is used only once
my @dummy = ( ${Header::table2colour}, ${Header::colouryellow} );
undef (@dummy);
# Dynamic ddns programm call.
my @ddnsprog = ("/usr/bin/ddns", "--config",
"/var/ipfire/ddns/ddns.conf",
- "update-all", "--force" );
+ "update-all");
my %settings=();
my $errormessage = '';
$settings{'ACTION'} = '';
+# Get supported ddns providers.
+my @providers = &GetProviders();
+
+# Hook to regenerate the configuration files, if cgi got called from command line.
+if ($ENV{"REMOTE_ADDR"} eq "") {
+ &GenerateDDNSConfigFile();
+ exit(0);
+}
+
&Header::showhttpheaders();
#Get GUI values
my @current = <FILE>;
close (FILE);
-# Get supported ddns providers.
-my @providers = &GetProviders();
-
#
# Save General Settings.
#
# Check if a password has been typed in.
# freedns.afraid.org does not require this field.
- if (($settings{'PASSWORD'} eq '') && ($settings{'SERVICE'} ne 'freedns.afraid.org')) {
+ if (($settings{'PASSWORD'} eq '') && ($settings{'SERVICE'} ne 'freedns.afraid.org') && ($settings{'SERVICE'} ne 'regfish.com')) {
$errormessage = $Lang::tr{'password not set'};
}
# Splitt hostname field into 2 parts for storrage.
my($hostname, $domain) = split(/\./, $settings{'HOSTNAME'}, 2);
+ # Handle enabled checkbox. When the checkbox is selected a "on" will be returned,
+ # if the checkbox is not checked nothing is returned in this case we set the value to "off".
+ if ($settings{'ENABLED'} ne 'on') {
+ $settings{'ENABLED'} = 'off';
+ }
+
# Handle adding new accounts.
if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
# Write out notice to logfile.
&General::log($Lang::tr{'ddns hostname added'});
- # Update ddns config file.
-
# Handle account edditing.
} elsif ($settings{'ACTION'} eq $Lang::tr{'update'}) {
$checked{'BEHINDROUTER'}{'FETCH_IP'} = '';
$checked{'BEHINDROUTER'}{$settings{'BEHINDROUTER'}} = "checked='checked'";
-$checked{'ENABLED'}{'on'} = ($settings{'ENABLED'} eq '' ) ? '' : "checked='checked'";
+$checked{'ENABLED'}{'on'} = '';
+$checked{'ENABLED'}{'off'} = '';
+$checked{'ENABLED'}{$settings{'ENABLED'}} = "checked='checked'";
# Show box for errormessages..
if ($errormessage) {
<tr>
<td class='base'>$Lang::tr{'enabled'}</td>
- <td><input type='checkbox' name='ENABLED' value='on' $checked{'ENABLED'}{'on'} /></td>
+ <td><input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td>
<td class='base'>$Lang::tr{'username'}</td>
<td><input type='text' name='LOGIN' value='$settings{'LOGIN'}' /></td>
</tr>
chomp(@current);
my @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]";
+ }
+
# Generate value for enable/disable checkbox.
- my $sync = "<font color='blue'>";
+ my $sync = '';
my $gif = '';
my $gdesc = '';
if ($temp[7] eq "on") {
$gif = 'on.gif';
$gdesc = $Lang::tr{'click to disable'};
- $sync = (&General::DyndnsServiceSync ($ip,$temp[1], $temp[2]) ? "<font color='green'>": "<font color='red'>") ;
+
+ # Check if the given hostname is a FQDN before doing a nslookup.
+ if (&General::validfqdn($hostname)) {
+ $sync = (&General::DyndnsServiceSync ($ip,$temp[1], $temp[2]) ? "<font color='green'>": "<font color='red'>") ;
+ }
+
$toggle_enabled = 'off';
} else {
+ $sync = "<font color='blue'>";
$gif = 'off.gif';
$gdesc = $Lang::tr{'click to enable'};
$toggle_enabled = 'on';
my ($provider, $hostname, $domain, $proxy, $wildcards, $username, $password, $enabled) = @settings;
# Skip entries if they are not (longer) supported.
- next if (!&General::is_part_of("$provider", @providers));
+ next unless ($provider ~~ @providers);
# Skip disabled entries.
next if ($enabled eq "off");
my $use_token = 0;
# Handle token based auth for various providers.
- if ($provider ~~ ["dns.lightningwirelabs.com", "regfish.com"] && $username eq "token") {
+ if ($provider ~~ ["dns.lightningwirelabs.com", "entrydns.net", "regfish.com"] && $username eq "token") {
$use_token = 1;
- # Handle token auth for freedns.afraid.org.
- } elsif ($provider eq "freedns.afraid.org" && $password eq "") {
+ # Handle token auth for freedns.afraid.org and regfish.com.
+ } elsif ($provider ~~ ["freedns.afraid.org", "regfish.com"] && $password eq "") {
$use_token = 1;
$password = $username;
}
# These providers need to be set to only use IPv4.
- if ($provider ~~ ["freedns.afraid.org", "nsupdate.info", "variomedia.de", "zoneedit.com"]) {
+ if ($provider ~~ ["freedns.afraid.org", "nsupdate.info", "opendns.com", "variomedia.de", "zoneedit.com"]) {
print FILE "proto = ipv4\n";
}