[ User ] Login

Bug 177: CLOSED

SliTaz Distro Tracker

Date: 2017-02-27 - Creator: Linea - Priority standard - 11 messages

Hi, there's some bugs, I had to hack the code to show the correct country - 
it was showing Switzerland :-)


get_geoloc() {
# freegeoip.net/{format}/{ip_or_hostname}
# Example: wget freegeoip.net/csv/${ip} -O /tmp/geoloc
-> #wget -q "${url}?sdt=geoloc" -O ${tmp}
-> #ip=$(cat ${tmp}) rm ${tmp}
wget -q freegeoip.net/csv/${ip} -O /tmp/geoloc
country=$(cat /tmp/geoloc | cut -d ',' -f 3 )
echo "$country" rm -f /tmp/geoloc
}

Then it returned a server error.

Messages

By: pankso on 2017-02-28 12:07

Hi Paul,

Thank for the feedback and testing SDT, I'm going to check that. In the 
cmdline tool we call sdt server to get our IP, then with this IP we can geoloc. 
Is sdt showing you a English IP ?

 scn.slitaz.org/?sdt=geoloc

By: Linea on 2017-02-28 18:02

Hi Christophe, out of the box I get :

Information sent to the SliTaz Distro Tracker
==========================================
User : Linea
Country : Switzerland
Release : SliTaz 5.0
Kernel : 3.2.71-slitaz
Running : live
==========================================
Send this data to SliTaz Distro Tracker ? 
Press 'c' then ENTER to continue or any other key to quit: 

If I hack the code I can get: 

Information sent to the SliTaz Distro Tracker
==========================================
User : Linea
Country : United Kingdom
Release : SliTaz 5.0
Kernel : 3.2.71-slitaz
Running : live
==========================================

Send this data to SliTaz Distro Tracker ? 
Press 'c' then ENTER to continue or any other key to quit: 

But when I press 'c' then ENTER, I get:

Sending data to:  scn.slitaz.org/

wget: server returned error: HTTP/1.0 400 Bad Request

By: Linea on 2017-02-28 18:15

Clicking on
 scn.slitaz.org/?sdt=geoloc
gives me 178.196.15.131 (a Swiss IP)
ERROR: sourcing msg.4
USER="Lexeii"
DATE="2017-02-28 22:37"
MSG="Hi Paul,

This IP address just hardcoded. Please, take a look: 
http://hg.slitaz.org/slitaz-forge/rev/0f1e69658f38#l3.87


Hi Christophe,

As I can see, you don't need an IP address, you need the country. Take this:

wget -q freegeoip.net/csv/ -O- | cut -d, -f3


Paul, you can test this code snippet too to be sure it return:
bug bug-20170222 bugs.cgi config.cgi favicon.ico images index.cgi lib plugins 
README style.css "Switzerland" for Christophe, and
bug bug-20170222 bugs.cgi config.cgi favicon.ico images index.cgi lib plugins 
README style.css "United Kingdom" for Paul.

By the way, it returns "Ukraine" for me, that is quite correct."
ERROR: sourcing msg.5
USER="Lexeii"
DATE="2017-02-28 22:40"
MSG="Sorry, I wanted only make unordered list here using asterisks (stars).
Let me use dashes instead of asterisks and repeat this part again:


Paul, you can test this code snippet too to be sure it return:
- "Switzerland" for Christophe, and
- "United Kingdom" for Paul.

By the way, it returns "Ukraine" for me, that is quite correct.
"

By: Lexeii on 2017-02-28 22:44

Now a little bit better.
But strange error again :-$
And the space before dashes was gone :(
So, generally speaking I will not be able to post the aligned piece of code :(

By: Linea on 2017-02-28 22:51

Hi Lexeii

wget -q freegeoip.net/csv/ -O- was pretty much was I was using as well to get 
the country.

There's still a problem for me uploading: 

Send this data to SliTaz Distro Tracker ? 
Press 'c' then ENTER to continue or any other key to quit: 

But when I press 'c' then ENTER, I get:

Sending data to: scn.slitaz.org/

wget: server returned error: HTTP/1.0 400 Bad Request

By: Lexeii on 2017-02-28 23:56

Good night, Paul.

It works for me:  scn.slitaz.org/?sdt
Note the last line :)

PS. I used the latest sdt code (locally updated the slitaz-tools repo) with 
my corrections to the get_geoloc() function.

By: pankso on 2017-03-01 10:13

here is the bug fix... fixed IP in code tthat I was using for local 
testing!

 hg.slitaz.org/slitaz-forge/rev/3dd8a58a91ba

By: Lexeii on 2017-03-01 11:21

Hi Christophe,

We can determine the country without that code anyway - please, read my 
messages here.


Citation from  freegeoip.net/ :

API

The HTTP API takes GET requests in the following schema:

freegeoip.net/{format}/{IP_or_hostname}

Supported formats are: csv, xml, json and jsonp. If no IP or hostname is 
provided, then your own IP is looked up.

By: pankso on 2021-01-22 21:12

Fixed for a while :)