1
1. What does the server do?
3
The server performs IP address and Wi-Fi based geolocation search.
5
2. How to set up the server?
7
After building geoclue, you will get a geoip-lookup binary that you can install
8
as a cgi-bin script inside your web server, or use the test application
9
("launch-web-server.sh") as below.
11
$ ./launch-web-server.sh start - to start the server
12
$ ./launch-web-server.sh stop - to stop the server
14
The script will set up the server at your http://localhost:12345.
16
And the URL will be - http://localhost:12345/cgi-bin/geoip-lookup
18
3. How should one query the server for IP address based Geolocation search?
22
a. You can provide a query string in the format of "?ip=<IP address>". After
23
installing the server at your localhost using the script, you can use -
25
http://localhost:12345/cgi-bin/geoip-lookup?ip=123.23.23.23
27
b. If you do not provide the query string, the server will autodetect
28
the client's external IP address.
30
If you have used launch-web-server.sh script to launch the server, the script
31
sets HTTP_CLIENT_IP (one of the many proxy variables checked by the server to
32
guess client's IP address) and thus a simple
33
http://localhost:12345/cgi-bin/geoip-lookup works.
35
4. How should one query the server for Wi-Fi based geolocation search?
37
The query string should be in the format of -
39
?wifi=mac:<mac address>|ssid:<ssid>|ss:<signal strength>[&...]
41
The server installed by the script at your localhost can be queried using the
44
http://localhost:12345/cgi-bin/geoip-lookup?wifi=mac:01-24-7c-bc-51-46%7Cssid:3x2x%7Css:-37&wifi=mac:09-86-3b-31-97-b2%7Cssid:belkin.7b2%7Css:-47&wifi=mac:28-cf-da-ba-be-13%7Cssid:HERESIARCH%20NETWORK%7Css:-49&wifi=mac:2b-cf-da-ba-be-10%7Cssid:%20ARCH%20GUESTS%7Css:-52&wifi=mac:08-56-3b-2b-e1-a8%7Cssid:belkin.1a8%7Css:-59&wifi=mac:02-1e-64-fd-df-67%7Cssid:Brown%20Cow%7Css:-59&wifi=mac:2a-cf-df-ba-be-10%7Cssid:%20ARCH%20GUESTS%7Css:-59
46
5. What is the output format of the server?
48
The server provides Geolocation information in JSON format.
50
An IP address based query would return -
52
{"ip":"123.23.23.23","latitude":10.25,"longitude":105.96669769287109,
53
"country_name":"Vietnam","country_code":"VN","region_name":"Phu Yen",
54
"city":"Vinh Long","accuracy":"city","timezone":"Asia/Phnom_Penh",
55
"attribution":"This product includes GeoLite data created by MaxMind,
56
available from http://www.maxmind.com\n"}
58
An Wi-Fi based query would return -
60
{"latitude":40.060449299999988,"longitude":-105.2094195,"accuracy":24}
62
6. What are the possible error scenarios and error messages?
64
The server gives the following errors in the following cases -
66
a. Invalid IP address -
67
{"error_code":0, "error_message":"Invalid IP address '123.23.23'"}
69
b. Reserved IP address -
70
{"error_code":1, "error_message":"Can not find the IP address '127.0.0.1' in the
73
c. Database not found by the server -
74
{"error_code":2, "error_message":"Can not open GeoLiteCity/GeoIP Binary database.
75
Set GEOIP_DATABASE_PATH env variable."}
77
The error codes in the JSON output shown above are enum values.
80
INVALID_IP_ADDRESS_ERR = 0,
86
https://git.gnome.org/browse/geocode-glib/tree/geocode-glib/geocode-ip-server/geoip-server.h