From patchwork Wed Nov 8 06:42:42 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: 1521 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id 4B7F360D81 for ; Tue, 7 Nov 2017 20:52:57 +0100 (CET) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id BB3153532; Tue, 7 Nov 2017 20:52:56 +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 74DE33547 for ; Tue, 7 Nov 2017 20:42:49 +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 B722E4039F for ; Tue, 7 Nov 2017 20:42:43 +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 F192E9F200 for ; Tue, 7 Nov 2017 20:42:42 +0100 (CET) Date: Tue, 7 Nov 2017 20:42:42 +0100 From: Peter =?utf-8?q?M=C3=BCller?= To: "development@lists.ipfire.org" Subject: [PATCH] display GeoIP information on active network connections in WebUI Message-ID: <20171107204242.15257272.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 the GeoIP flag for source and destination IP address on the connection tracking table in WebUI. This could possibly make network or firewall rule debugging easier. Signed-off-by: Peter Müller --- html/cgi-bin/connections.cgi | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/html/cgi-bin/connections.cgi b/html/cgi-bin/connections.cgi index 96f09012b..06dc74877 100644 --- a/html/cgi-bin/connections.cgi +++ b/html/cgi-bin/connections.cgi @@ -23,6 +23,7 @@ use strict; use Net::IPv4Addr qw( :all ); use Switch; +use Geo::IP::PurePerl; # enable only the following on debugging purpose #use warnings; @@ -31,6 +32,7 @@ use Switch; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +require "${General::swroot}/geoip-functions.pl"; my $colour_multicast = "#A0A0A0"; @@ -372,6 +374,7 @@ print < +   @@ -386,6 +389,7 @@ print < +   @@ -409,10 +413,16 @@ print < $Lang::tr{'source ip and port'} + + $Lang::tr{'country'} + $Lang::tr{'dest ip and port'} + $Lang::tr{'country'} + + $Lang::tr{'download'} /
$Lang::tr{'upload'} @@ -540,6 +550,16 @@ foreach my $line (@conntrack) { my $bytes_in = format_bytes($bytes[0]); my $bytes_out = format_bytes($bytes[1]); + my $gi1 = Geo::IP::PurePerl->new(); + my $ccode1 = $gi1->country_code_by_name($sip_ret); + my $fcode1 = lc($ccode1); + my $flag_icon1 = &GeoIP::get_flag_icon($fcode1); + + my $gi2 = Geo::IP::PurePerl->new(); + my $ccode2 = $gi2->country_code_by_name($dip_ret); + my $fcode2 = lc($ccode2); + my $flag_icon2 = &GeoIP::get_flag_icon($fcode2); + # Format TTL $ttl = format_time($ttl); @@ -601,6 +621,9 @@ foreach my $line (@conntrack) { $sport_extra + + + $dip @@ -613,6 +636,9 @@ foreach my $line (@conntrack) { $dport_extra + + + $bytes_in / $bytes_out