Display GeoIP flag on ipinfo.cgi in the WebUI.
This might make firewall rule debugging easier and fixes bug #10946.
Signed-off-by: Peter Müller peter.mueller@link38.eu --- html/cgi-bin/ipinfo.cgi | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/html/cgi-bin/ipinfo.cgi b/html/cgi-bin/ipinfo.cgi index 16541f126..689d05a0e 100644 --- a/html/cgi-bin/ipinfo.cgi +++ b/html/cgi-bin/ipinfo.cgi @@ -21,6 +21,7 @@
use CGI; use IO::Socket; +use Geo::IP::PurePerl; use strict;
# enable only the following on debugging purpose @@ -30,6 +31,7 @@ use strict; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +require "${General::swroot}/geoip-functions.pl";
my %cgiparams=();
@@ -49,6 +51,11 @@ if (&General::validip($addr)) { my $iaddr = inet_aton($addr); my $hostname = gethostbyaddr($iaddr, AF_INET); if (!$hostname) { $hostname = $Lang::tr{'lookup failed'}; } + + my $gi = Geo::IP::PurePerl->new(); + my $ccode = $gi->country_code_by_name($addr); + my $fcode = lc($ccode); + my $flag_icon = &GeoIP::get_flag_icon($fcode);
my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort => 43, Proto => 'tcp'); if ($sock) @@ -81,7 +88,7 @@ if (&General::validip($addr)) { @lines = ( "$Lang::tr{'unable to contact'} $whoisname" ); }
- &Header::openbox('100%', 'left', $addr . ' (' . $hostname . ') : '.$whoisname); + &Header::openbox('100%', 'left', $addr . " <a href='country.cgi#$fcode'><img src='$flag_icon' border='0' align='absmiddle' title='$ccode' /></a> (" . $hostname . ') : '.$whoisname); print "<pre>\n"; foreach my $line (@lines) { print &Header::cleanhtml($line,"y");