~deejay1/geoclue/master

« back to all changes in this revision

Viewing changes to src/geoip-server/API-Documentation.txt

  • Committer: Zeeshan Ali (Khattak)
  • Date: 2013-08-16 13:37:21 UTC
  • Revision ID: git-v1:2ce41f923aacd8e5d8e1b096d2791544be9e2a67
Import geoip code from geocode-glib

geocode-glib is meant to only do (reverse-)geocoding and all geolocation
code belongs to us.

This means we now drop our geocode-glib dep and instead directly depend
on:

json-glib-1.0 >= 0.14
libsoup-2.4
geoip (Only needed by geoip server)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
1. What does the server do?
 
2
 
 
3
The server performs IP address and Wi-Fi based geolocation search.
 
4
 
 
5
2. How to set up the server?
 
6
 
 
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.
 
10
 
 
11
$ ./launch-web-server.sh start - to start the server
 
12
$ ./launch-web-server.sh stop - to stop the server
 
13
 
 
14
The script will set up the server at your http://localhost:12345.
 
15
 
 
16
And the URL will be - http://localhost:12345/cgi-bin/geoip-lookup
 
17
 
 
18
3. How should one query the server for IP address based Geolocation search?
 
19
 
 
20
There are 2 ways -
 
21
 
 
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 -
 
24
 
 
25
   http://localhost:12345/cgi-bin/geoip-lookup?ip=123.23.23.23
 
26
 
 
27
b. If you do not provide the query string, the server will autodetect
 
28
the client's external IP address.
 
29
 
 
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.
 
34
 
 
35
4. How should one query the server for Wi-Fi based geolocation search?
 
36
 
 
37
The query string should be in the format of -
 
38
 
 
39
?wifi=mac:<mac address>|ssid:<ssid>|ss:<signal strength>[&...]
 
40
 
 
41
The server installed by the script at your localhost can be queried using the
 
42
following URL -
 
43
 
 
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
 
45
 
 
46
5. What is the output format of the server?
 
47
 
 
48
The server provides Geolocation information in JSON format.
 
49
 
 
50
An IP address based query would return -
 
51
 
 
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"}
 
57
 
 
58
An Wi-Fi based query would return -
 
59
 
 
60
{"latitude":40.060449299999988,"longitude":-105.2094195,"accuracy":24}
 
61
 
 
62
6. What are the possible error scenarios and error messages?
 
63
 
 
64
The server gives the following errors in the following cases -
 
65
 
 
66
a. Invalid IP address -
 
67
{"error_code":0, "error_message":"Invalid IP address '123.23.23'"}
 
68
 
 
69
b. Reserved IP address -
 
70
{"error_code":1, "error_message":"Can not find the IP address '127.0.0.1' in the
 
71
database"}
 
72
 
 
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."}
 
76
 
 
77
The error codes in the JSON output shown above are enum values.
 
78
 
 
79
typedef enum {
 
80
        INVALID_IP_ADDRESS_ERR = 0,
 
81
        INVALID_ENTRY_ERR,
 
82
        DATABASE_ERR
 
83
} GeoipServerError;
 
84
 
 
85
They are defined in
 
86
https://git.gnome.org/browse/geocode-glib/tree/geocode-glib/geocode-ip-server/geoip-server.h