]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
dns.cgi: Perform server checks on user request
authorStefan Schantl <stefan.schantl@ipfire.org>
Wed, 8 Jan 2020 14:24:59 +0000 (15:24 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Wed, 8 Jan 2020 16:44:55 +0000 (17:44 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
html/cgi-bin/dns.cgi
langs/en/cgi-bin/en.pl

index 2042d5bfc29674081a1d9940edc5e444658ad9d5..54ca8d0d79c3ca671da12e8742b65f88009281e7 100755 (executable)
@@ -56,6 +56,8 @@ my @ISP_nameserver_files = ( "/var/run/dns1", "/var/run/dns2" );
 # File which contains the ca-certificates.
 my $ca_certs_file = "/etc/ssl/certs/ca-bundle.crt";
 
+my $check_servers;
+
 my %color = ();
 my %mainsettings = ();
 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
@@ -223,6 +225,11 @@ if (($cgiparams{'SERVERS'} eq $Lang::tr{'save'}) || ($cgiparams{'SERVERS'} eq $L
 
        # Write the changed hash to the config file.
        &General::writehasharray($servers_file, \%dns_servers);
+
+## Handle request to check the servers.
+#
+} elsif ($cgiparams{'SERVERS'} eq $Lang::tr{'dns check servers'}) {
+       $check_servers = 1;
 }
 
 # Hash to store the generic DNS settings.
@@ -404,16 +411,25 @@ print <<END;
                                <td align="center">
                                        <strong>$Lang::tr{'remark'}</strong>
                                </td>
-
+END
+       # Check if the status should be displayed.
+       if ($check_servers) {
+print <<END
                                <td align="center">
                                        <strong>$Lang::tr{'status'}</strong>
                                </td>
+END
+;
+       }
+
+print <<END
 
                                <td align="center" colspan="3">
                                        <strong>$Lang::tr{'action'}</strong>
                                </td>
                        </tr>
 END
+;
 
                # Check the usage of ISP assigned nameservers is enabled.
                my $id = 1;
@@ -478,7 +494,7 @@ END
                                my $status_colour;
 
                                # Only grab the status if the nameserver is enabled.
-                               if ($enabled eq "enabled") {
+                               if (($check_servers) && ($enabled eq "enabled")) {
                                        $status = &check_nameserver("$nameserver", "ping.ipfire.org", "$settings{'PROTO'}", "$tls_hostname");
                                }
 
@@ -546,12 +562,18 @@ print <<END;
                                <td align="center" $col>
                                        $remark
                                </td>
-
-                               <td align="center" $col>
-                                       <strong><font color="$status_colour"><abbr title="$status_message">$status_short</abbr></font></strong>
-                               </td>
 END
 ;
+                               # Display server status if requested.
+                               if ($check_servers) {
+print <<END
+                                       <td align="center" $col>
+                                               <strong><font color="$status_colour"><abbr title="$status_message">$status_short</abbr></font></strong>
+                                       </td>
+END
+;
+                               }
+
                                # Check if the id is greater than "2".
                                #
                                # Nameservers with an ID's of one or two are ISP assigned,
@@ -619,7 +641,10 @@ END
 print <<END;
                        <tr>
                                <form method="post" action="$ENV{'SCRIPT_NAME'}">
-                                       <td colspan="9" align="right"><input type="submit" name="SERVERS" value="$Lang::tr{'add'}"></td>
+                                       <td colspan="9" align="right">
+                                               <input type="submit" name="SERVERS" value="$Lang::tr{'add'}">
+                                               <input type="submit" name="SERVERS" value="$Lang::tr{'dns check servers'}">
+                                       </td>
                                </form>
                        </tr>
                </table>
index fdfae843469dd1c55b64fe597b74182f602fc52a..34e9bceac07e68659ba4668e7e79c2eba247517b 100644 (file)
 'dns address done' => 'The DNS server address settings are going to be saved.',
 'dns address recon' => 'Trying to reconnect!',
 'dns check failed' => 'DNS check failed',
+'dns check servers' => 'Check DNS Servers',
 'dns configuration' => 'DNS Configuration',
 'dns could not add server' => 'Could not add server - Reason:',
 'dns desc' => 'If the red0 interface gets the IP address information via DHCP from the provider, the DNS server addresses will be set automatically. Now here you are able to change these DNS server IP addresses with your own ones.',