Add GeoIP information to ipinfo.cgi
Message ID | 5686AC3C.8040805@web.de |
---|---|
State | Dropped |
Headers |
Return-Path: <development-bounces@lists.ipfire.org> Received: from mail01.ipfire.org (mail01.tremer.info [172.28.1.200]) by septima.ipfire.org (Postfix) with ESMTP id 23C6660D7D for <patchwork@ipfire.org>; Fri, 1 Jan 2016 17:41:48 +0100 (CET) Received: from hedwig.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 93AAC1FA3; Fri, 1 Jan 2016 17:41:47 +0100 (CET) Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=212.227.17.12; helo=mout.web.de; envelope-from=itsuperhack@web.de; receiver=development@lists.ipfire.org Received: from mout.web.de (mout.web.de [212.227.17.12]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPS id 1F83ED9A for <development@lists.ipfire.org>; Fri, 1 Jan 2016 17:41:44 +0100 (CET) Received: from 127.0.0.1 ([193.90.12.87]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0LzsC7-1aAHq82fQJ-0153mx for <development@lists.ipfire.org>; Fri, 01 Jan 2016 17:41:44 +0100 To: IPFire Development <development@lists.ipfire.org> From: IT Superhack <itsuperhack@web.de> Subject: [PATCH] Add GeoIP information to ipinfo.cgi X-Enigmail-Draft-Status: N1110 Message-ID: <5686AC3C.8040805@web.de> Date: Fri, 1 Jan 2016 17:41:32 +0100 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="oi0kdPU7iWjLVtAkmtIoKV1mxVCKmltiO" X-Provags-ID: V03:K0:y6AmNvQU61B5lr39zqaVikGfZVq/HNgt7+CK/lz6KpLkpqBUHER 5mboXk1H4HuTKJsQ9rYpAxKBf85ILWu3M+S5J5WXfeHuYIxFfyToj4PdBPXZJDmzbFFZo5t 5/KWEPJ6hsLUUsM0oasNbwskFrz8P2416yYdsxB8OOP28DkNLz34FUBzct1NaqGK0e75u58 J0e4kHCWFDroqwdfeiU1w== X-UI-Out-Filterresults: notjunk:1; V01:K0:YbeAGFbMBmk=:Zp1/tR462FWtIwvZGkAu0g kfxIupb1rl9xAHl/W3ighLvZ6mW+h4Z5hxYr0k9TJFvxkHoOddmSYcZKGoqwAjrxawGuuJIn7 AZt4Oja5z8s1YImIUQm37WT/TV4/2ODImKUi1Giu0kvRFLHfVeZ9RraHcR8JFwPMDzru/iwEB 9qv/OVbyxF3RqZTHU6ElxoNAPBaug9cQtwad7JjQr767HO9F+QF2Ln6+S4XP/kjOovZ8VHJ51 dxWEe6IHGESDOSknOtDaCAitFjkw/Gst2fzxD3Cr9QdOVIJc2/XJ710lqhC8Ez0WS/VHGJdTe 2JI/l9vSmtJ9IvPKvRB+ZpufxI5s+edEX9RwHljyS6rrhpt/nOt3Mlqov90H226/w3blM4PkZ PaZYPg0R9BV+9kfOiXZbGO3wupfyMuo/CjQvdKae2/yfv+ScHf8QHLP38ibhEM9hafacQVXC+ ZEHqiM7+bpzlA4s/tTCivcHuYI/jP6CxpJk5YPoEhw5o/86+sljCfGae2qxOAF5iQbQ3UfwlO FCrNq9bslETV8KiJ5+1g9KNkxxbpklIs9d1SQtlAYykFuSmyt/upUYRdbzbO3ptkf0Mm/FnVP bBPjeWGtTXcM9dbAnY63+hGK0Hj9BymEbZ0YvUjH2q1owBnmwWT2S/RFxBFR4xj/kkJ1Vq8Bk igq0blBZFKSfnF9Fyi2XtAEerHuI9bD+bE8jzjMX5n3JwNNyAYypKKv3gLmeuMGLhy1WYBGqJ 0zKGyCtfZI13T3RgmcoDbnwUH0NsLz3C/ck5FKSf4ftKYkNLGiNsquogaPhjUxfXNC2ikTvKb Hh1tqAG X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: IPFire development talk <development.lists.ipfire.org> List-Unsubscribe: <http://lists.ipfire.org/mailman/options/development>, <mailto:development-request@lists.ipfire.org?subject=unsubscribe> List-Archive: <http://lists.ipfire.org/pipermail/development/> List-Post: <mailto:development@lists.ipfire.org> List-Help: <mailto:development-request@lists.ipfire.org?subject=help> List-Subscribe: <http://lists.ipfire.org/mailman/listinfo/development>, <mailto:development-request@lists.ipfire.org?subject=subscribe> Errors-To: development-bounces@lists.ipfire.org Sender: "Development" <development-bounces@lists.ipfire.org> |
Message
IT Superhack
Jan. 2, 2016, 3:41 a.m. UTC
Add the GeoIP information to the general ip information
(address, reverse dns name) on the ipinfo.cgi.
The ip address is given to Geo::IP::PurePerl first, then
the country code and the flag icon path are queried.
Fixes a feature request filed under bug #10946
Signed-off-by: Timmothy Wilson <itsuperhack@web.de>
---
Comments
Hello development-list, I was just wondering if something is wrong with the patch (code error/bad style?) because there was no answer within ~ two weeks. Best regards, Timmothy Wilson IT Superhack: > Add the GeoIP information to the general ip information > (address, reverse dns name) on the ipinfo.cgi. > > The ip address is given to Geo::IP::PurePerl first, then > the country code and the flag icon path are queried. > > Fixes a feature request filed under bug #10946 > > Signed-off-by: Timmothy Wilson <itsuperhack@web.de> > --- > diff --git a/html/cgi-bin/ipinfo.cgi b/html/cgi-bin/ipinfo.cgi > index 71098a2..cebce23 100644 > --- a/html/cgi-bin/ipinfo.cgi > +++ b/html/cgi-bin/ipinfo.cgi > @@ -20,6 +20,7 @@ > ############################################################################### > > use IO::Socket; > +use Geo::IP::PurePerl; > use strict; > > # enable only the following on debugging purpose > @@ -27,10 +28,13 @@ use strict; > #use CGI::Carp 'fatalsToBrowser'; > > require '/var/ipfire/general-functions.pl'; > +require "${General::swroot}/geoip-functions.pl"; > require "${General::swroot}/lang.pl"; > require "${General::swroot}/header.pl"; > > my %cgiparams=(); > +my $s; > +my @key; > > &Header::showhttpheaders(); > > @@ -52,6 +56,14 @@ next if $addr eq ""; > my $iaddr = inet_aton($addr); > my $hostname = gethostbyaddr($iaddr, AF_INET); > if (!$hostname) { $hostname = $Lang::tr{'lookup failed'}; } > + > + # geoip lookup > + my $geoaddr = Geo::IP::PurePerl->new(); > + my $ccode = $geoaddr->country_code_by_name($addr); > + my $fcode = lc($ccode); > + # Get flag icon for of the country. > + my $flag_icon = &GeoIP::get_flag_icon($ccode); > + > > my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort => 43, Proto => 'tcp'); > if ($sock) > @@ -84,7 +96,9 @@ next if $addr eq ""; > @lines = ( "$Lang::tr{'unable to contact'} $whoisname" ); > } > > - &Header::openbox('100%', 'left', $addr . ' (' . $hostname . ') : '.$whoisname); > + # include geoip information here > + &Header::openbox('100%', 'left', $addr . ' <a href=\'/cgi-bin/country.cgi#' . $fcode . '\'><img src=\'' . $flag_icon . '\' border=\'0\' align=\'absmiddle\' alt=\'' > +.$ccode .'\' title=\'' . $ccode . '\'></a> (' . $hostname . ') : '.$whoisname); > print "<pre>\n"; > foreach my $line (@lines) { > print &Header::cleanhtml($line,"y"); >
Hi, no I guess this is kind of alright. I just would have expected a bit more feedback from the others here. Seems to be a bit of a lonely show at the moment. I have stated that at an other occasion recently that I do not think that the information from a whois query and the geoip database is that much related, but if it helps people that is okay for me. However this seems to be an issue: The rules are pretty simple: If you comply and agree with the IPFire Project Contributor Agreement, then you just add a line saying Signed-off-by: Random Developer <random@developer.example.org> using your real name. No pseudonyms or anonymous contributions. From: http://wiki.ipfire.org/devel/git/tags Best, -Michael On Mon, 2016-01-18 at 17:56 +0100, IT Superhack wrote: > Hello development-list, > > I was just wondering if something is wrong > with the patch (code error/bad style?) because there > was no answer within ~ two weeks. > > Best regards, > Timmothy Wilson > > IT Superhack: > > Add the GeoIP information to the general ip information > > (address, reverse dns name) on the ipinfo.cgi. > > > > The ip address is given to Geo::IP::PurePerl first, then > > the country code and the flag icon path are queried. > > > > Fixes a feature request filed under bug #10946 > > > > Signed-off-by: Timmothy Wilson <itsuperhack@web.de> > > --- > > diff --git a/html/cgi-bin/ipinfo.cgi b/html/cgi-bin/ipinfo.cgi > > index 71098a2..cebce23 100644 > > --- a/html/cgi-bin/ipinfo.cgi > > +++ b/html/cgi-bin/ipinfo.cgi > > @@ -20,6 +20,7 @@ > > ################################################################## > > ############# > > > > use IO::Socket; > > +use Geo::IP::PurePerl; > > use strict; > > > > # enable only the following on debugging purpose > > @@ -27,10 +28,13 @@ use strict; > > #use CGI::Carp 'fatalsToBrowser'; > > > > require '/var/ipfire/general-functions.pl'; > > +require "${General::swroot}/geoip-functions.pl"; > > require "${General::swroot}/lang.pl"; > > require "${General::swroot}/header.pl"; > > > > my %cgiparams=(); > > +my $s; > > +my @key; > > > > &Header::showhttpheaders(); > > > > @@ -52,6 +56,14 @@ next if $addr eq ""; > > my $iaddr = inet_aton($addr); > > my $hostname = gethostbyaddr($iaddr, AF_INET); > > if (!$hostname) { $hostname = $Lang::tr{'lookup failed'}; > > } > > + > > + # geoip lookup > > + my $geoaddr = Geo::IP::PurePerl->new(); > > + my $ccode = $geoaddr->country_code_by_name($addr); > > + my $fcode = lc($ccode); > > + # Get flag icon for of the country. > > + my $flag_icon = &GeoIP::get_flag_icon($ccode); > > + > > > > my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, > > PeerPort => 43, Proto => 'tcp'); > > if ($sock) > > @@ -84,7 +96,9 @@ next if $addr eq ""; > > @lines = ( "$Lang::tr{'unable to contact'} > > $whoisname" ); > > } > > > > - &Header::openbox('100%', 'left', $addr . ' (' . $hostname > > . ') : '.$whoisname); > > + # include geoip information here > > + &Header::openbox('100%', 'left', $addr . ' <a href=\'/cgi > > -bin/country.cgi#' . $fcode . '\'><img src=\'' . $flag_icon . '\' > > border=\'0\' align=\'absmiddle\' alt=\'' > > +.$ccode .'\' title=\'' . $ccode . '\'></a> (' . $hostname . ') : > > '.$whoisname); > > print "<pre>\n"; > > foreach my $line (@lines) { > > print &Header::cleanhtml($line,"y"); > > > >