Geo location and the raspberry pie as webserver
As mentioned I coded a new version of ip_to_country.
length 4071407 bytes.
wget http://panteltje.com/panteltje/newsflex/ip_to_country-0.4.tgz
Use tar -zxf ip_to_country-0.4.tgz to unpack it, see README file for compile
and install instructions.
When the original /var/log/apache2/access.log looks like
103.211.106.194 - - [26/Jun/2018:16:04:09 +0000] "GET / HTTP/1.1" 200 3205 "-"
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.7 (KHTML,
like Gecko) Version/9.1.2 Safari/601.7.7"
then using
ip_to_country -t /var/log/apache2/access.log -f 2
shows
103.211.106.194 "IN" India - - [26/Jun/2018:16:04:09 +0000] "GET / HTTP/1.1"
200 3205 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6)
AppleWebKit/601.7.7 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
You can just leave it running that way, and it will start showing the log plus
country info starting at the last log line before the moment you started it.
Or use
ip_to_country -i 103.211.106.194
103.211.106.194 "IN" India
Many other ways exist to use it from a script of course.
No support for IPV6 as I cannot test that.
It finds, in its > 500,000 entries database, the correct entry in about 18
steps using successive approximation,
so even on a fully loaded pi it seems timeless and uses no detectable processor
cycles when run.
For those C coders maybe worth a peek howitsdone :-)
Experimental of course, released under the GPL.
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|