WebUI: print more information on used nameservers

Message ID 20170908195416.71a95d4c.peter.mueller@link38.eu
State Superseded
Headers
Series WebUI: print more information on used nameservers |

Commit Message

Peter Müller Sept. 9, 2017, 3:54 a.m. UTC
  Show rDNS/PTR entry and country flag of the used nameservers on the
nameserver status list at "netexternal.cgi".

These information might be useful for debugging, or are just "nice to
have" and do not harm anything. :-)

Signed-off-by: Peter Müller <peter.mueller@link38.eu>
---
  

Patch

diff --git a/html/cgi-bin/netexternal.cgi b/html/cgi-bin/netexternal.cgi
index 299612d4c..a091afdf7 100644
--- a/html/cgi-bin/netexternal.cgi
+++ b/html/cgi-bin/netexternal.cgi
@@ -25,9 +25,13 @@  use strict;
 #use warnings;
 #use CGI::Carp 'fatalsToBrowser';
 
+use IO::Socket;
+use Geo::IP::PurePerl;
+
 require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
+require "${General::swroot}/geoip-functions.pl";
 require "${General::swroot}/graphs.pl";
 
 my %color = ();
@@ -99,6 +103,12 @@  if ( $querry[0] ne~ ""){
 						<strong>$Lang::tr{'nameserver'}</strong>
 					</th>
 					<th align="center">
+						<strong>$Lang::tr{'flag'}</strong>
+					</th>
+					<th align="center">
+						<strong>$Lang::tr{'rdns'}</strong>
+					</th>
+					<th align="center">
 						<strong>$Lang::tr{'status'}</strong>
 					</th>
 				</tr>
@@ -139,9 +149,22 @@  END
 
 		my $table_colour = ($id++ % 2) ? $color{'color22'} : $color{'color20'};
 
+		# Get rDNS entry for nameserver (might be useful)
+		my $iaddr = inet_aton($nameserver);
+		my $rdns = gethostbyaddr($iaddr, AF_INET);
+	        if (!$rdns) { $rdns = $Lang::tr{'lookup failed'}; }
+		
+		# Get country flag for the nameserver (might be useful)
+		my $gi = Geo::IP::PurePerl->new();
+	        my $ccode = $gi->country_code_by_name($nameserver);
+       		my $fcode = lc($ccode);
+	        my $flag_icon = &GeoIP::get_flag_icon($fcode);
+
 		print <<END;
 			<tr bgcolor="$table_colour">
 				<td>$nameserver</td>
+				<td align="center"><a href="../country.cgi#$fcode"><img src="$flag_icon" border="0" align="absmiddle" alt="$ccode"></a></td>	
+				<td>$rdns</td>
 				<td bgcolor="$bgcolour" align="center">
 					<font color="$colour"><strong>$message</strong></font>
 				</td>
@@ -271,3 +294,4 @@  sub check_dnssec($$) {
 
 	return $aware + $validating;
 }
+
diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl
index 0138cbc02..a63eb3160 100644
--- a/langs/de/cgi-bin/de.pl
+++ b/langs/de/cgi-bin/de.pl
@@ -1902,6 +1902,7 @@ 
 'quick playlist' => 'Quick Playlist',
 'ram' => 'RAM-Speicher',
 'random number generator daemon' => 'Random Number Generator Daemon',
+'rdns' => 'rDNS',
 'read bytes' => 'Gelesene Bytes',
 'read list' => 'Liste der Leseberechtigten',
 'real address' => 'Reale Addresse',
diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl
index b3aee5a2b..13c18f4c8 100644
--- a/langs/en/cgi-bin/en.pl
+++ b/langs/en/cgi-bin/en.pl
@@ -1936,6 +1936,7 @@ 
 'quick playlist' => 'Quick Playlist',
 'ram' => 'RAM',
 'random number generator daemon' => 'Random Number Generator Daemon',
+'rdns' => 'rDNS',
 'read bytes' => 'Read Bytes',
 'read list' => 'list with readonly hosts',
 'real address' => 'Real Address',