@@ -6,15 +6,22 @@ lua-resty-maxminddb - A Lua library for reading [MaxMind's Geolocation database
6
6
Prerequisites
7
7
---
8
8
9
- ** Note **
9
+ ** Bug fixed **
10
10
11
11
[ Error at lookup IP] ( https://github.com/anjia0532/lua-resty-maxminddb/issues/5 )
12
12
13
13
[ bad argument #1 to 'concat' (table expected, got nil)] ( https://github.com/anjia0532/lua-resty-maxminddb/issues/4 )
14
14
15
+ [ Memory leak] ( https://github.com/anjia0532/lua-resty-maxminddb/issues/6 )
16
+
17
+
18
+ ** Note**
15
19
- [ maxmind/libmaxminddb] [ ]
20
+
16
21
- [ openresty] [ ]
22
+
17
23
- [ GeoLite2 Free Downloadable Databases] [ linkGeolite2FreeDownloadableDatabases ]
24
+
18
25
- [ maxmind/geoipupdate] [ ]
19
26
20
27
@@ -27,19 +34,20 @@ opm get anjia0532/lua-resty-maxminddb
27
34
Synopsis
28
35
---
29
36
```
37
+ local cjson = require 'cjson'
30
38
local geo = require 'resty.maxminddb'
39
+ if not geo.initted() then
40
+ geo.init("/path/to/GeoLite2-City.mmdb")
41
+ end
42
+ local res,err = geo.lookup(ngx.var.arg_ip or ngx.var.remote_addr) --support ipv6 e.g. 2001:4860:0:1001::3004:ef68
31
43
32
- local maxm = geo.new("/path/to/GeoLite2-City.mmdb")
33
-
34
- local res,err = maxm:lookup(ngx.var.arg_ip or ngx.var.remote_addr) --support ipv6 e.g. 2001:4860:0:1001::3004:ef68
35
-
36
- if not res then
37
- ngx.log(ngx.ERR,'failed to lookup by ip ,reason:',err)
44
+ if not res then
45
+ ngx.log(ngx.ERR,'failed to lookup by ip ,reason:',err)
38
46
end
39
47
40
48
ngx.say("full :",cjson.encode(res))
41
49
if ngx.var.arg_node then
42
- ngx.say("node name:",ngx.var.arg_node," ,value:", cjson.encode(res[ngx.var.arg_node] or {}))
50
+ ngx.say("node name:",ngx.var.arg_node," ,value:", cjson.encode(res[ngx.var.arg_node] or {}))
43
51
end
44
52
```
45
53
0 commit comments