Closed alex5imon closed 10 years ago
also ipinfo.io
which is also the service used by tzupdate
if i'm not mistaken
But why do we need it? We already have it from tzupdate!
On 07/04/2014 17:39, Alex Simon wrote:
We can get the geolocation with one of these free services: http://www.iplocation.net/ http://www.geobytes.com/IpLocator.htm?GetLocation for example
— Reply to this email directly or view it on GitHub https://github.com/KanoComputing/kano-profile/issues/23.
But if you want to do it properly, here is the MaxMind free database: http://dev.maxmind.com/geoip/geoip2/geolite2/
And the Python API for it: https://github.com/maxmind/geoip-api-python https://github.com/appliedsec/pygeoip
To get your external IP, you can use: curl ipecho.net/plain
On 07/04/2014 17:39, Alex Simon wrote:
We can get the geolocation with one of these free services: http://www.iplocation.net/ http://www.geobytes.com/IpLocator.htm?GetLocation for example
— Reply to this email directly or view it on GitHub https://github.com/KanoComputing/kano-profile/issues/23.
The idea is that we need a more or less accurate geolocation (not just country/timezone)
@zsero point is accurate. Just to keep info together, tzupdate log is always saved under /var/log/tzupdate.log
and the syslog if it's enabled. It is created by the initial udhcpc script:
https://github.com/KanoComputing/kano-toolset/blob/master/udhcpc/kano.script#L47
I've just used the MaxMind database for Shopify and it works well.
I've just found this, looks exactly made for our purpose: http://www.telize.com/
We need to request this: http://www.telize.com/geoip
Data looks like this: { country: "United Kingdom", dma_code: "0", timezone: "Europe/London", area_code: "0", ip: "92.24.107.28", asn: "AS13285", continent_code: "EU", isp: "TalkTalk Communications Limited", longitude: -0.13, latitude: 51.5, country_code: "GB", country_code3: "GBR" }
or like this:
{ "timezone": "Europe\/Rome", "isp": "Prometeus di Daniela Agro", "region_code": "18", "country": "Italy", "dma_code": "0", "area_code": "0", "region": "Umbria", "ip": "37.247.54.42", "asn": "AS34971", "continent_code": "EU", "city": "Milano", "longitude": 12.6, "latitude": 42.7833, "country_code": "IT", "country_code3": "ITA" }
On 08/04/2014 11:08, Mathew Keegan wrote:
I've just used the MaxMind database for Shopify and it works well.
— Reply to this email directly or view it on GitHub https://github.com/KanoComputing/kano-profile/issues/23#issuecomment-39831373.
I've added get_ip_location to utils.py.
def get_ip_location():
import requests
try:
r = requests.get('http://www.telize.com/geoip')
if r.ok:
return r.ok, None, r.json()
else:
return r.ok, r.text, None
except Exception:
return False, 'Connection error', None
you use it like this (pprint is for pretty printing only):
from pprint import pprint
success, error, data = get_location()
if success:
pprint(data)
else:
print error
Two possible ways to do it:
added get_location
to kano.utils
returns a dict in this format:
{'continent_code': u'EU',
'country': u'United Kingdom',
'country_code': u'GB',
'latitude': 51.5,
'longitude': -0.13}
now adding it to profile sync
Implemented a less precise version, which only includes country_code and continent_code
@tancredi 's suggestion is not to do it from the client, but just use the server. I'm removing it now.
We can get the geolocation with one of these free services: http://www.iplocation.net/ http://www.geobytes.com/IpLocator.htm?GetLocation for example