From patchwork Wed Nov 8 07:04:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Peter_M=C3=BCller?= X-Patchwork-Id: 1523 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id 567BE61281 for ; Tue, 7 Nov 2017 21:05:00 +0100 (CET) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id E57EC3549; Tue, 7 Nov 2017 21:04:59 +0100 (CET) Received: from mx.link38.eu (mx.link38.eu [188.68.43.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx.link38.eu", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 15BD73547 for ; Tue, 7 Nov 2017 21:04:56 +0100 (CET) X-Virus-Scanned: ClamAV at mx.link38.eu Received: from mx-fra.brokers.link38.eu (mx-fra.brokers.link38.eu [10.141.75.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx.link38.eu (Postfix) with ESMTPS id 643714039F for ; Tue, 7 Nov 2017 21:04:51 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx-fra.brokers.link38.eu (Postfix) with ESMTPSA id AD9B29F200 for ; Tue, 7 Nov 2017 21:04:50 +0100 (CET) Date: Tue, 7 Nov 2017 21:04:50 +0100 From: Peter =?utf-8?q?M=C3=BCller?= To: "development@lists.ipfire.org" Subject: [PATCH] display GeoIP information on ipinfo.cgi Message-ID: <20171107210450.081bf696.peter.mueller@link38.eu> Organization: Link38 MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" 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 --- 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 . " (" . $hostname . ') : '.$whoisname); print "
\n";
 	foreach my $line (@lines) {
 		print &Header::cleanhtml($line,"y");