From: "Peter Müller" <peter.mueller@link38.eu>
To: development@lists.ipfire.org
Subject: Re: [PATCH] display GeoIP information on active network connections in WebUI
Date: Sat, 11 Nov 2017 21:30:18 +0100 [thread overview]
Message-ID: <20171111213018.29d3cae8.peter.mueller@link38.eu> (raw)
In-Reply-To: <1510266885.2945.7.camel@ipfire.org>
[-- Attachment #1: Type: text/plain, Size: 5972 bytes --]
Hello Michael,
the patches look good.
Thanks for working on this.
However, I think for simple sites such as the DNS server list
or ipinfo.cgi, where we have only 1 or 2 queries, we do not need
to load the complete database to RAM.
Best regards,
Peter Müller
> Hi,
>
> I just posted a patch that does this.
>
> Please have a look at it.
>
> Best,
> -Michael
>
> On Wed, 2017-11-08 at 22:52 +0100, Peter Müller wrote:
> > Hello Michael,
> >
> > > Basically this patch looks simple and good to me.
> >
> > Thanks, finally. :-)
> > >
> > > But since we are using the perl module quite a bit, could we not put
> > > those few lines into a function so that if we need to change anything
> > > we do that everywhere at once?
> > >
> > > And secondly, I have some systems that have thousands of open
> > > connections very often to the same IP addresses. Could we not add a
> > > caching layer so that this isn't being looked up multiple times for the
> > > same IP address if that is an expensive operation?
> >
> > Could you (or somebody else) do this, please? I am afraid this is
> > one step to far for me at the moment.
> >
> > Thanks and best regards,
> > Peter Müller
> > >
> > > -Michael
> > >
> > > On Tue, 2017-11-07 at 20:42 +0100, Peter Müller wrote:
> > > > 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 <peter.mueller(a)link38.eu>
> > > > ---
> > > > 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 <<END;
> > > > <a href="?sort_field=5&sort_order=d"><img style="width:10px" src="/images/up.gif" alt=""></a>
> > > > <a href="?sort_field=5&sort_order=a"><img style="width:10px" src="/images/down.gif" alt=""></a>
> > > > </th>
> > > > + <th> </th>
> > > > <th style='text-align:center' colspan='2'>
> > > > <a href="?sort_field=1&sort_order=d"><img style="width:10px" src="/images/up.gif" alt=""></a>
> > > > <a href="?sort_field=1&sort_order=a"><img style="width:10px" src="/images/down.gif" alt=""></a>
> > > > @@ -386,6 +389,7 @@ print <<END;
> > > > <a href="?sort_field=4&sort_order=d"><img style="width:10px" src="/images/up.gif" alt=""></a>
> > > > <a href="?sort_field=4&sort_order=a"><img style="width:10px" src="/images/down.gif" alt=""></a>
> > > > </th>
> > > > + <th> </th>
> > > > <th style='text-align:center'>
> > > > <a href="?sort_field=8&sort_order=d"><img style="width:10px" src="/images/up.gif" alt=""></a>
> > > > <a href="?sort_field=8&sort_order=a"><img style="width:10px" src="/images/down.gif" alt=""></a>
> > > > @@ -409,10 +413,16 @@ print <<END;
> > > > <th style='text-align:center' colspan='2'>
> > > > $Lang::tr{'source ip and port'}
> > > > </th>
> > > > + <th style='text-align:center'>
> > > > + $Lang::tr{'country'}
> > > > + </th>
> > > > <th style='text-align:center' colspan='2'>
> > > > $Lang::tr{'dest ip and port'}
> > > > </th>
> > > > <th style='text-align:center'>
> > > > + $Lang::tr{'country'}
> > > > + </th>
> > > > + <th style='text-align:center'>
> > > > $Lang::tr{'download'} /
> > > > <br>$Lang::tr{'upload'}
> > > > </th>
> > > > @@ -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) {
> > > > </a>
> > > > $sport_extra
> > > > </td>
> > > > + <td style='text-align:center; background-color:$sip_colour;'>
> > > > + <a href='country.cgi#$fcode1'><img src='$flag_icon1' border='0' align='absmiddle' title='$ccode1'></a>
> > > > + </td>
> > > > <td style='text-align:center; background-color:$dip_colour;'>
> > > > <a href='/cgi-bin/ipinfo.cgi?ip=$dip'>
> > > > <span style='color:#FFFFFF;'>$dip</span>
> > > > @@ -613,6 +636,9 @@ foreach my $line (@conntrack) {
> > > > </a>
> > > > $dport_extra
> > > > </td>
> > > > + <td style='text-align:center; background-color:$dip_colour;'>
> > > > + <a href='country.cgi#$fcode2'><img src='$flag_icon2' border='0' align='absmiddle' title='$ccode2'></a>
> > > > + </td>
> > > > <td style='text-align:center'>
> > > > $bytes_in / $bytes_out
> > > > </td>
> >
> >
next prev parent reply other threads:[~2017-11-11 20:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-07 19:42 Peter Müller
2017-11-07 23:07 ` Michael Tremer
2017-11-08 21:52 ` Peter Müller
2017-11-09 22:32 ` [PATCH 1/2] geoip-functions.pl: Fix typos and formatting Michael Tremer
2017-11-09 22:32 ` [PATCH 2/2] GeoIP: Add lookup function for convenience Michael Tremer
2017-11-12 12:27 ` Peter Müller
2017-11-12 12:27 ` [PATCH 1/2] geoip-functions.pl: Fix typos and formatting Peter Müller
2017-11-09 22:34 ` [PATCH] display GeoIP information on active network connections in WebUI Michael Tremer
2017-11-11 20:30 ` Peter Müller [this message]
2017-11-12 12:23 ` Michael Tremer
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=20171111213018.29d3cae8.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