Debian Codegraph @

cmd/atomdns/handlers/geoip/README.md

raw
1 # Name
2
3 _geoip_ - add geographical location data
4
5 # Description
6
7 The _geoip_ handler adds geographical location data associated with the client IP. You can install a database
8 on Debian systems with `apt-get install geoip-database`, or see https://mailfud.org/geoip-legacy/.
9
10 There is no automatic reloading of the databases under the assumption they will not change _that_ often.
11
12 If an IP address does not have associated geographical location data, nothing is added to the context. If the
13 _ecs_ handler is active and has added data to the context the address from there is used instead of the
14 sources address of the query.
15
16 # Syntax
17
18 ```
19 geoip {
20 city DBFILE4 [DBFILE6]
21 asn DBFILE4 [DBFILE6]
22 }
23 ```
24
25 - `city` and `asn` define the database files that should be used for country, city or AS number
26 lookups. If the path is relative the path from `root` will be prepended. At least one database must be
27 loaded.
28
29 # Context
30
31 The following values will be stored in the context of a request and can be used by other handlers.
32
33 The continent codes are: `AF`: Africa, `AN`: Antarctica, `AS`: Asia, `EU`: Europe, `NA`: North America,
34 `OC`: Oceania, `SA`: South America.
35
36 | Key | Type | Example | Description |
37 | :----------------------- | :--------- | :------------ | :--------------------------------- |
38 | `geoip/city` | `string` | Cambridge | The city name in English language. |
39 | `geoip/city/region` | `[]string` | ENG TWH | Regional ISO 3166-2 codes. |
40 | `geoip/country` | `string` | GB | Country ISO 3166-1 code. |
41 | `geoip/country/eu` | `bool` | false | Country is EU member. |
42 | `geoip/continent` | `string` | EU | Continent code. |
43 | `geoip/latitude` | `float64` | 52.2242 | Base 10, max available precision. |
44 | `geoip/longitude` | `float64` | 0.1315 | Base 10, max available precision. |
45 | `geoip/timezone` | `string` | Europe/London | The time zone. |
46 | `geoip/asn` | `int` | 37 | The AS number. |
47 | `geoip/asn/organization` | `string` | Example Org | The AS organization. |
48
49 # Example
50
51 Here we add location data to the request's context, so that _template_ can use it in the template creation.
52
53 ```conffile
54 example.org. {
55 geoip {
56 city testdata/GeoIPCity.dat
57 }
58
59 template .* {
60 mytemplate.go.tmpl
61 }
62 }
63 ```
64
65 # See Also
66
67 atomdns-ecs(7).