]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
dns.cgi: Display DNS system status.
authorStefan Schantl <stefan.schantl@ipfire.org>
Wed, 8 Jan 2020 17:00:15 +0000 (18:00 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Wed, 8 Jan 2020 17:00:15 +0000 (18:00 +0100)
For this, a test query to the local unbound instance will be
sent and if the DNS system work properly can be answerd.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
html/cgi-bin/dns.cgi
langs/en/cgi-bin/en.pl

index 54ca8d0d79c3ca671da12e8742b65f88009281e7..41212ea4ad2cbb3dd7b3fcaa26020f29d624e813 100755 (executable)
@@ -56,6 +56,9 @@ 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";
 
+# Server which is used, to determine if the whole DNS system works properly.
+my $dns_test_server = "ping.ipfire.org";
+
 my $check_servers;
 
 my %color = ();
@@ -393,7 +396,35 @@ END
 sub show_nameservers () {
        &Header::openbox('100%', 'center', "$Lang::tr{'dns title'}");
 
+       my $dns_status_string;
+       my $dns_status_col;
+
+       # Test if the DNS system is working.
+       #
+       # Simple send a request to unbound and check if it can resolve the
+       # DNS test server.
+       my $dns_status_ret = &check_nameserver("127.0.0.1", "$dns_test_server", "UDP");
+
+       if ($dns_status_ret eq "2") {
+               $dns_status_string = "$Lang::tr{'working'}";
+               $dns_status_col = "${Header::colourgreen}";
+       } else {
+               $dns_status_string = "$Lang::tr{'broken'} status: $dns_status_ret";
+               $dns_status_col = "${Header::colourred}";
+       }
+
 print <<END;
+               <table width='100%'>
+                       <tr>
+                               <td>
+                                       <strong>$Lang::tr{'status'}:&nbsp;</strong>
+                                       <strong><font color='$dns_status_col'>$dns_status_string</font></strong>
+                               </td>
+                       </tr>
+               </table>
+
+               <br>
+
                <table class="tbl" width='100%'>
                        <tr>
                                <td align="center">
index 34e9bceac07e68659ba4668e7e79c2eba247517b..fb864440502fd8c615a5e1a5cf5da642a2333315 100644 (file)
 'wlanap wlan status' => 'WLan Status',
 'wol wakeup' => 'WakeUp',
 'workgroup' => 'Workgroup',
+'working' => 'Working',
 'written bytes' => 'Bytes Written',
 'xtaccess all error' => 'You cannot set an external access to ALL, that is done in the port forwarding record.',
 'xtaccess bad transfert' => 'If you specify a port destination range, the source range must be identical !',