]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/netexternal.cgi
add GeoIP and rDNS information to used nameservers
[ipfire-2.x.git] / html / cgi-bin / netexternal.cgi
index 39c50e15c9a542f5fc438cee34ccecabb8243c9d..4393393e081f07326de37e0b7648c2c2d59683c4 100644 (file)
@@ -25,9 +25,12 @@ use strict;
 #use warnings;
 #use CGI::Carp 'fatalsToBrowser';
 
+use IO::Socket;
+
 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 = ();
@@ -98,6 +101,12 @@ if ( $querry[0] ne~ ""){
                                        <th align="center">
                                                <strong>$Lang::tr{'nameserver'}</strong>
                                        </th>
+                                       <th align="center">
+                                               <strong>$Lang::tr{'country'}</strong>
+                                       </th>
+                                       <th align="center">
+                                               <strong>$Lang::tr{'rdns'}</strong>
+                                       </th>
                                        <th align="center">
                                                <strong>$Lang::tr{'status'}</strong>
                                        </th>
@@ -111,22 +120,26 @@ END
                my $status = &check_dnssec($nameserver, "ping.ipfire.org");
 
                my $colour = "";
+               my $bgcolour = "";
                my $message = "";
 
                # DNSSEC Not supported
                if ($status == 0) {
                        $message = $Lang::tr{'dnssec not supported'};
-                       $colour = ${Header::colourred};
+                       $colour = "white";
+                       $bgcolour = ${Header::colourred};
 
                # DNSSEC Aware
                } elsif ($status == 1) {
                        $message = $Lang::tr{'dnssec aware'};
-                       $colour = ${Header::colouryellow};
+                       $colour = "black";
+                       $bgcolour = ${Header::colouryellow};
 
                # DNSSEC Validating
                } elsif ($status == 2) {
                        $message = $Lang::tr{'dnssec validating'};
-                       $colour = ${Header::colourgreen};
+                       $colour = "white";
+                       $bgcolour = ${Header::colourgreen};
 
                # Error
                } else {
@@ -135,11 +148,27 @@ END
 
                my $table_colour = ($id++ % 2) ? $color{'color22'} : $color{'color20'};
 
+               # collect more information about name server (rDNS, GeoIP country code)
+               my $ccode = &GeoIP::lookup($nameserver);
+               my $flag_icon = &GeoIP::get_flag_icon($ccode);
+
+               my $iaddr = inet_aton($nameserver);
+               my $rdns = gethostbyaddr($iaddr, AF_INET);
+               if (!$rdns) { $rdns = $Lang::tr{'lookup failed'}; }
+
                print <<END;
                        <tr bgcolor="$table_colour">
-                               <td>$nameserver</td>
-                               <td bgcolor="$colour" align="center">
-                                       <font color='white'><strong>$message</strong></font>
+                               <td>
+                                       $nameserver
+                               </td>
+                               <td align="center">
+                                       <a href='country.cgi#$ccode'><img src="$flag_icon" border="0" alt="$ccode" title="$ccode" /></a>
+                               </td>
+                               <td align="center">
+                                       $rdns
+                               </td>
+                               <td bgcolor="$bgcolour" align="center">
+                                       <font color="$colour"><strong>$message</strong></font>
                                </td>
                        </tr>
 END