public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: "Peter Müller" <peter.mueller@link38.eu>
To: development@lists.ipfire.org
Subject: [PATCH] display GeoIP information for hosts blocked by Guardian
Date: Sat, 02 Dec 2017 19:39:40 +0100	[thread overview]
Message-ID: <20171202193940.0fa7006d.peter.mueller@link38.eu> (raw)

[-- Attachment #1: Type: text/plain, Size: 2718 bytes --]

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 <peter.mueller(a)link38.eu>
---
 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 <<END;
 	<table width='60%'>
 		<tr>
-			<td colspan='2' class='base' bgcolor='$color{'color20'}'><b>$Lang::tr{'guardian blocked hosts'}</b></td>
+			<td class='base' bgcolor='$color{'color20'}'><b>$Lang::tr{'ip address'}</b></td>
+			<td class='base' align='center' bgcolor='$color{'color20'}'><b>$Lang::tr{'country'}</b></td>
+			<td class='base' bgcolor='$color{'color20'}'></td>
+			<td class='base' align='center' bgcolor='$color{'color20'}'><b>$Lang::tr{'unblock'}</b></td>
 		</tr>
 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 <<END;
 			<tr>
-				<td width='80%' class='base' $col><a href='/cgi-bin/ipinfo.cgi?ip=$blocked_host'>$blocked_host</a></td>
+				<td width='20%' class='base' $col><a href='/cgi-bin/ipinfo.cgi?ip=$blocked_host'>$blocked_host</a></td>
+				<td width='20%' class='base' align='center' $col>
+						<a href='/cgi-bin/country.cgi#$ccode'><img src='$flag_icon' border='0' align='absmiddle' alt='$ccode' title='$ccode' /></a>
+				</td>
+				<td width='30%' class='base' $col></td>
 				<td width='20%' align='center' $col>
 					<form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'>
 						<input type='image' name='$Lang::tr{'unblock'}' src='/images/delete.gif' title='$Lang::tr{'unblock'}' alt='$Lang::tr{'unblock'}'>
@@ -834,7 +846,7 @@ END
 
 		# Print notice that currently no hosts are blocked.
 		print "<tr>\n";
-		print "<td class='base' colspan='2'>$Lang::tr{'guardian no entries'}</td>\n";
+		print "<td class='base' colspan='4'>$Lang::tr{'guardian no entries'}</td>\n";
 		print "</tr>\n";
 	}
 
-- 
2.13.6



                 reply	other threads:[~2017-12-02 18:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171202193940.0fa7006d.peter.mueller@link38.eu \
    --to=peter.mueller@link38.eu \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox