From patchwork Thu Nov 16 09:10:43 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: 1540 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id EFCC760B0D for ; Wed, 15 Nov 2017 23:10:53 +0100 (CET) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 504D31181; Wed, 15 Nov 2017 23:10:53 +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 92092954 for ; Wed, 15 Nov 2017 23:10:50 +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 871484016A for ; Wed, 15 Nov 2017 23:10:44 +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 12CD59F4A5 for ; Wed, 15 Nov 2017 23:10:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=link38.eu; s=201711; t=1510783844; bh=H4f+z2/4dgN/a+2MKb5weyyI/MTV7Dj94rHfCmPLGFw=; h=Date:From:To:Subject:From; b=YU/Z5E7154f9X/lE0r4VMfeE40J5Eeu/syHefmTE8HeIh6cb8dVPxdTGPtiqTrU9Z WYVrgCXHJQ8mbWVBUbT/EGZHumoV44GQJrBu/XxN6h2wZ48uV5BAE15Fg6M/u17ygs 1kiEtQUCA8pMAopsfQJTTAL9SGjCJyYwkspxMqgAGMPF9GiHzoxDEo5Tf0d7O6fXBS JZEyNKpEx+VbLw+UB/GrSsx1dfWRoKhlkHzPFcrf8fBdkPZ2ZgEnk53esam9WOpvpM oTY/Fyj/l6lO54Rw9oKUKcrBcQO0fuNmdVBhwsWV129Vy+At2FU3oPVkGLtB6MkyEH EXuHY5uh2vFFQ== Date: Wed, 15 Nov 2017 23:10:43 +0100 From: Peter =?utf-8?q?M=C3=BCller?= To: "development@lists.ipfire.org" Subject: [PATCH v2] display GeoIP information on active network connections Message-ID: <20171115231043.501e6f36.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 information on active network connections in WebUI. Use newly implemented function in /var/ipfire/geoip-functions.pl . Signed-off-by: Peter Müller --- html/cgi-bin/connections.cgi | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/html/cgi-bin/connections.cgi b/html/cgi-bin/connections.cgi index 96f09012b..e9e9e335c 100644 --- a/html/cgi-bin/connections.cgi +++ b/html/cgi-bin/connections.cgi @@ -31,6 +31,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"; @@ -379,6 +380,7 @@ print < +   @@ -386,6 +388,7 @@ print < +   @@ -409,10 +412,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 +549,12 @@ foreach my $line (@conntrack) { my $bytes_in = format_bytes($bytes[0]); my $bytes_out = format_bytes($bytes[1]); + # enumerate GeoIP information + my $srcccode = &GeoIP::lookup($sip_ret); + my $src_flag_icon = &GeoIP::get_flag_icon($srcccode); + my $dstccode = &GeoIP::lookup($dip_ret); + my $dst_flag_icon = &GeoIP::get_flag_icon($dstccode); + # Format TTL $ttl = format_time($ttl); @@ -601,6 +616,9 @@ foreach my $line (@conntrack) { $sport_extra + + $srcccode + $dip @@ -613,6 +631,9 @@ foreach my $line (@conntrack) { $dport_extra + + $dstccode + $bytes_in / $bytes_out