Skip to content

Commit 5bc2ec6

Browse files
authored
Update README.md
1 parent 05104df commit 5bc2ec6

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

README.md

+16-8
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ lua-resty-maxminddb - A Lua library for reading [MaxMind's Geolocation database
66
Prerequisites
77
---
88

9-
**Note**
9+
**Bug fixed**
1010

1111
[Error at lookup IP](https://github.com/anjia0532/lua-resty-maxminddb/issues/5)
1212

1313
[bad argument #1 to 'concat' (table expected, got nil)](https://github.com/anjia0532/lua-resty-maxminddb/issues/4)
1414

15+
[Memory leak](https://github.com/anjia0532/lua-resty-maxminddb/issues/6)
16+
17+
18+
**Note**
1519
- [maxmind/libmaxminddb][]
20+
1621
- [openresty][]
22+
1723
- [GeoLite2 Free Downloadable Databases][linkGeolite2FreeDownloadableDatabases]
24+
1825
- [maxmind/geoipupdate][]
1926

2027

@@ -27,19 +34,20 @@ opm get anjia0532/lua-resty-maxminddb
2734
Synopsis
2835
---
2936
```
37+
local cjson = require 'cjson'
3038
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
3143
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)
3846
end
3947
4048
ngx.say("full :",cjson.encode(res))
4149
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 {}))
4351
end
4452
```
4553

0 commit comments

Comments
 (0)