From patchwork Sun Dec 3 05:39:40 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: 1572 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id 63B8360D91 for ; Sat, 2 Dec 2017 19:39:58 +0100 (CET) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 497CA1D54; Sat, 2 Dec 2017 19:39:57 +0100 (CET) Received: from mx.link38.eu (mx.link38.eu [IPv6:2a03:4000:17:39a::1]) (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 655691C79 for ; Sat, 2 Dec 2017 19:39:53 +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 F19AB4016F for ; Sat, 2 Dec 2017 19:39:42 +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 B45439F18D for ; Sat, 2 Dec 2017 19:39:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=link38.eu; s=201711; t=1512239981; x=1575311981; bh=Q78ynP+cdVd+7Y0aDfdfL1gWoDtNIvECl2884EKT3Gw=; h=Date:From:To:Subject:Message-ID:Content-Type:From:To:Subject:Date: Cc; b=Nd3Jv31N1JOW6DVGAHrZMxYKFmosaWbt02vapVoJBnBZ54AoEmk2m5xz7zROYunq/ 6oV7/WwTkLl0U1wxIJAGOluX8ogkus9iez9Rh9kI+GapTwP6NlFh5hlnRWWX8WWYRr lTDEBxMbXvV5diBMBeZAbCSqYlCGShnjU9Ditk5/QtPdkv4V/QmUylS/cL/lNgjH6N pHludjxp7cMNEOaln5THdH1QUYOcCOKVTunRazDhiDMocIvQYPo6JLt7mr2deRAWsc EmhwFnEEEBCk2aClr116HzvkMPWudASIWvEuGo2Yw43ptGfKszCJyTUQaHH9P4mgiq AeJ1Xbl2xgkNg== Date: Sat, 2 Dec 2017 19:39:40 +0100 From: Peter =?utf-8?q?M=C3=BCller?= To: "development@lists.ipfire.org" Subject: [PATCH] display GeoIP information for hosts blocked by Guardian Message-ID: <20171202193940.0fa7006d.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 for blocked hosts at guardian.cgi in the WebUI. This makes spotting blocked local IPs (grey flag with question mark) easier. Enumerating the rDNS entry, unfortunately, takes way too long. Signed-off-by: Peter Müller --- html/cgi-bin/guardian.cgi | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/html/cgi-bin/guardian.cgi b/html/cgi-bin/guardian.cgi index e15501ef5..3bfa1b522 100644 --- a/html/cgi-bin/guardian.cgi +++ b/html/cgi-bin/guardian.cgi @@ -30,6 +30,7 @@ use Guardian::Socket; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +require "${General::swroot}/geoip-functions.pl"; #workaround to suppress a warning when a variable is used only once my @dummy = ( @@ -791,7 +792,10 @@ sub showBlockedBox() { print < - $Lang::tr{'guardian blocked hosts'} + $Lang::tr{'ip address'} + $Lang::tr{'country'} + + $Lang::tr{'unblock'} END @@ -814,9 +818,17 @@ END $col="bgcolor='$color{'color20'}'"; } + # enumerate GeoIP information for blocked host... + my $ccode = &GeoIP::lookup($blocked_host); + my $flag_icon = &GeoIP::get_flag_icon($ccode); + print < - $blocked_host + $blocked_host + + $ccode + +
@@ -834,7 +846,7 @@ END # Print notice that currently no hosts are blocked. print "\n"; - print "$Lang::tr{'guardian no entries'}\n"; + print "$Lang::tr{'guardian no entries'}\n"; print "\n"; }