Skip to content

lilien1010/lua-resty-maxminddb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A lua client for maxmind db

to get ip location with ip database offerd by maxmind

Installation

  1. install libmaxminddb from this repo
  2. download ip database from maxmind

Demo code:

local maxminddb 	=	require("resty.maxminddb")
local geo_file 		=	'/home/lua/common_data/GeoIP2-Country-20161004.mmdb'
local ip_db		=	maxminddb.new(geo_file) 

local client_ip 	=	ngx.req.get_uri_args()['ip']
local out 		=	{}
if not client_ip then
	return nil
end
local res,err 		=	ip_db:get_area_code(client_ip)
ngx.print( res )

Bug Reports

Please report bugs by filing an issue with our GitHub issue tracker at https://github.com/lilien1010/libmaxminddb/issues or if the bug is casued by libmaxminddb tracker at https://github.com/maxmind/libmaxminddb/issues

Copyright and License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

a lua module to get ip location with maxmind db

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages