dns.cgi: Display DNS system status.

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>
This commit is contained in:
Stefan Schantl
2020-01-08 18:00:15 +01:00
parent 4314099302
commit 770ea81ee5
2 changed files with 32 additions and 0 deletions

View File

@@ -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">

View File

@@ -2956,6 +2956,7 @@
'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 !',