From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: development@lists.ipfire.org Subject: Re: Feedback wanted on feature to show blocked IPs per country Date: Mon, 17 Feb 2014 17:29:36 +0100 Message-ID: <1392654576.30526.44.camel@rice-oxley.tremer.info> In-Reply-To: <6480d856603853637dd7193bf88a3d36.squirrel@webmail.mailadmin.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1347431270992722307==" List-Id: --===============1347431270992722307== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi, On Sun, 2014-02-16 at 07:24 +0100, alf(a)i100.no wrote: > Hi >=20 > I preliminary version is available at : > https://github.com/alfh/ipfire-2.x/tree/feature_firewalllogcountry >=20 > Currently I am struggling at getting the new functionality available > in the menu, so I am asking if anyone has a tip on how to do that ? > I've tried to edit the file : > --- a/config/menu/70-log.menu > +++ b/config/menu/70-log.menu > @@ -33,6 +33,11 @@ > 'title' =3D> "$Lang::tr{'firewall logs > port'}", > 'enabled' =3D> 1 > }; > + $sublogs->{'43.firewallcountry'} =3D {'caption' =3D> > $Lang::tr{'firewall logs country'}, > + 'uri' =3D> > '/cgi-bin/logs.cgi/firewalllogcountry.dat', > + 'title' =3D> "$Lang::tr{'firewall logs > country'}", > + 'enabled' =3D> 1 > + }; >=20 > but that does not seem to be enough. Basically, that's it. The CGI script must be there and be executable and you are fine. -Michael >=20 > Regards > Alf >=20 >=20 > Den ons, februar 12, 2014, 20:41 skrev Michael Tremer: > > Hi, > > > > On Wed, 2014-02-12 at 18:21 +0100, Alf H=C3=B8gemark wrote: > >> Hi > >> > >> Based on the existing firewalllogip.dat and firewalllogport.dat, I > want > >> a similair function to show > >> which countries gets blocked, to see which country is mainly > targeting > >> my servers. > >> > >> I've made a preliminary prototype, you can see it here : > >> > https://github.com/alfh/ipfire-2.x/commit/a99ee9ce4fcdc9e41bfdfd7bd169324d1= a0dcee0 > >> > >> This works on my existing 2.13 Core75. > >> There is no right menu, it is just a preliminary prototype as of > now. > >> > >> > >> What I basically have done, is to copy firewalllogip.dat and > >> showrequestfromip.dat, and modified them > >> so they work on "country for ip address" rather than inidividual ip > >> address. > >> > >> This raises a few questions in my mind : > >> > >> 1. > >> Code duplication. By just copying the firewalllogip.dat, I > duplicate a > >> lot of code. > >> To me, this also seems to be the case already, where > firewalllogip.dat > >> and firewalllogport.dat containing > >> a lot of duplicated code. > >> Any ideas how to avoid this ? > >> Has it been discussed to try to minimze the existing code > duplication in > >> the cgi-bin files ? > > > > You may create a perl file that will be included which provides > > functions for both scripts. > > > >> 2. > >> Do think "local ip addresses" should turn up in > firewalllogcounty.dat ? > > > > No. > > > >> Here is the main part of my code : > >> my $gi =3D Geo::IP::PurePerl->new(); > >> .... > >> > >> if($_ =3D~ /SRC\=3D([\d\.]+)/){ > >> my $srcaddr=3D$1; > >> my $ccode =3D $gi->country_code_by_name($srcaddr); > >> my $fcode; > >> > >> # TODO: should local IP adresses be include as unknown, or excluded > >> from the statistics totally ? > >> # TODO: it would be nice to be able to group local IPs into "red", > >> "green", "blue" etc > >> if( $ccode eq "") { > >> $ccode =3D "unknown"; > >> } > >> else { > >> $tabjc{$ccode} =3D $tabjc{$ccode} + 1 ; > >> if(($tabjc{$ccode} =3D=3D 1) && ($lines < $pienumber)) { $lines =3D > >> $lines + 1; } > >> $linesjc++; > >> } > >> } > >> > >> As you can see, I now decide to not include the local ip addresses. > >> I also currently do not differentiate between local ip addresses > and ip > >> addresses where country code is actually unknown. > >> I'll have to check if Geo::IP has some functionality to tell me if > the > >> address is part of "non routable addresses", like 192.168.x.y. > > > > There certainly is a perl module (like this > > > http://search.cpan.org/~neely/Data-Validate-IP-0.11/lib/Data/Validate/IP.pm= ), > > but we also have got some simple checks in setddns.pl for example. > > > >> 3. > >> Is there functionality existing in ipfire cgi-bin code to check if > an ip > >> address is part of the netmask of the "green", "red", "blue", > "yellow" > >> interface ? > >> If so, I think I would like to treat them like "countries". > > > > Yes. Have a look at /var/ipfire/general-functions.pl > > > >> 4. > >> Do other people find this functionality useful ? > > > > Why not? > > > >> > >> Regards > >> Alf > >> > >> _______________________________________________ > >> Development mailing list > >> Development(a)lists.ipfire.org > >> http://lists.ipfire.org/mailman/listinfo/development > > > > --===============1347431270992722307==--