All Projects → anjia0532 → lua-resty-maxminddb

anjia0532 / lua-resty-maxminddb

Licence: Apache-2.0 License
A Lua library for reading MaxMind's Geolocation database

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to lua-resty-maxminddb

pf-azure-sentinel
Parse pfSense/OPNSense logs using Logstash, GeoIP tag entities, add additional context to logs, then send to Azure Sentinel for analysis.
Stars: ✭ 24 (-66.67%)
Mutual labels:  geoip, maxmind, maxmind-geoip
geoip2-rs
Fast GeoIP2 Reader for Rust
Stars: ✭ 25 (-65.28%)
Mutual labels:  geoip, maxmind, maxmind-geoip
lua-resty-ipcidr
A simple and very fast function to check against CIDR
Stars: ✭ 17 (-76.39%)
Mutual labels:  luajit, openresty
mmdbwriter
Go library for writing MaxMind DB (mmdb) files
Stars: ✭ 44 (-38.89%)
Mutual labels:  geoip, maxmind
phi
an api-gateway based on openresty
Stars: ✭ 23 (-68.06%)
Mutual labels:  luajit, openresty
clickhouse-maxmind-geoip
A demonstration how to use ClickHouse with MaxMind GeoIP2 databases for geolocaiton
Stars: ✭ 82 (+13.89%)
Mutual labels:  maxmind, maxmind-geoip
locus
MMDB reader for geolocation and ASN lookup of IP addresses
Stars: ✭ 93 (+29.17%)
Mutual labels:  maxmind-db, geoip
lua-resty-jump-consistent-hash
consistent hash for openresty
Stars: ✭ 24 (-66.67%)
Mutual labels:  luajit, openresty
GeoIP2-perl
Perl API for MaxMind's GeoIP2 web services and databases
Stars: ✭ 18 (-75%)
Mutual labels:  geoip, maxmind
geoip
🌚 🌍 🌝 GeoIP 规则文件加强版,同时支持定制 V2Ray dat 格式路由规则文件 geoip.dat 和 MaxMind mmdb 格式文件 Country.mmdb。Enhanced edition of GeoIP files for V2Ray, Xray-core, Trojan-Go, Clash and Leaf, with replaced CN IPv4 CIDR available from ipip.net, appended CIDR lists and more.
Stars: ✭ 524 (+627.78%)
Mutual labels:  geoip, maxmind-geoip
cdn-up-and-running
CDN Up and Running - an introduction about how modern CDNs works
Stars: ✭ 131 (+81.94%)
Mutual labels:  luajit, openresty
lua-resty-aries
openresty and lua multi-function template
Stars: ✭ 47 (-34.72%)
Mutual labels:  luajit, openresty
MaxMind-DB-Reader-python
Python MaxMind DB reader extension
Stars: ✭ 131 (+81.94%)
Mutual labels:  geoip, maxmind
GeoLite2-Country
GeoLite2-Country.mmdb.gz CDN files based on Free Open Source CDN jsDelivr!
Stars: ✭ 69 (-4.17%)
Mutual labels:  geoip, maxmind
MaxMind-DB-Reader-java
Java reader for the MaxMind DB format
Stars: ✭ 88 (+22.22%)
Mutual labels:  geoip, maxmind
ZfSnapGeoip
Maxmind Geoip module for Zend Framework 2
Stars: ✭ 15 (-79.17%)
Mutual labels:  geoip, maxmind-geoip
nodejs-geoip2ws
Maxmind GeoIP2 Web Services for Node.js
Stars: ✭ 47 (-34.72%)
Mutual labels:  geoip, maxmind
sawmill
Sawmill is a JSON transformation Java library
Stars: ✭ 92 (+27.78%)
Mutual labels:  geoip, maxmind
GeoIP2-ruby
Ruby API for GeoIP2 webservice client and database reader
Stars: ✭ 41 (-43.06%)
Mutual labels:  geoip, maxmind
nott
The New OTT Platform - an excuse to discuss and design a simple edge computing platform
Stars: ✭ 46 (-36.11%)
Mutual labels:  luajit, openresty

Name

lua-resty-maxminddb - A Lua library for reading MaxMind's Geolocation database format (aka mmdb or geoip2).

Prerequisites

Bug fixed

Apology for infringement

Note

Installation

opm get anjia0532/lua-resty-maxminddb

Synopsis

  local cjson = require 'cjson'
  local geo = require 'resty.maxminddb'
  if not geo.initted() then
      geo.init("/path/to/GeoLite2-City.mmdb")
  end
  local res,err = geo.lookup(ngx.var.arg_ip or ngx.var.remote_addr) --support ipv6 e.g. 2001:4860:0:1001::3004:ef68

  if not res then
      ngx.log(ngx.ERR,'failed to lookup by ip ,reason:',err)
  end

  ngx.say("full :",cjson.encode(res))
  if ngx.var.arg_node then
     ngx.say("node name:",ngx.var.arg_node," ,value:", cjson.encode(res[ngx.var.arg_node] or {}))
  end
  #ipv4
  $ curl localhost/ip=114.114.114.114&node=city
  #ipv6
  #$ curl localhost/ip=2001:4860:0:1001::3004:ef68&node=country
  full :{"city":{"geoname_id":1799962,"names":{"en":"Nanjing","ru":"Нанкин","fr":"Nankin","pt-BR":"Nanquim","zh-CN":"南京","es":"Nankín","de":"Nanjing","ja":"南京市"}},"subdivisions":[{"geoname_id":1806260,"names":{"en":"Jiangsu","fr":"Province de Jiangsu","zh-CN":"江苏省"},"iso_code":"32"}],"country":{"geoname_id":1814991,"names":{"en":"China","ru":"Китай","fr":"Chine","pt-BR":"China","zh-CN":"中国","es":"China","de":"China","ja":"中国"},"iso_code":"CN"},"registered_country":{"geoname_id":1814991,"names":{"en":"China","ru":"Китай","fr":"Chine","pt-BR":"China","zh-CN":"中国","es":"China","de":"China","ja":"中国"},"iso_code":"CN"},"location":{"time_zone":"Asia\/Shanghai","longitude":118.7778,"accuracy_radius":50,"latitude":32.0617},"continent":{"geoname_id":6255147,"names":{"en":"Asia","ru":"Азия","fr":"Asie","pt-BR":"Ásia","zh-CN":"亚洲","es":"Asia","de":"Asien","ja":"アジア"},"code":"AS"}}
  node name:city ,value:{"geoname_id":1799962,"names":{"en":"Nanjing","ru":"Нанкин","fr":"Nankin","pt-BR":"Nanquim","zh-CN":"南京","es":"Nankín","de":"Nanjing","ja":"南京市"}}

prettify

full: {
    "city": {
        "geoname_id": 1799962,
        "names": {
            "en": "Nanjing",
            "ru": "Нанкин",
            "fr": "Nankin",
            "pt-BR": "Nanquim",
            "zh-CN": "南京",
            "es": "Nankín",
            "de": "Nanjing",
            "ja": "南京市"
        }
    },
    "subdivisions": [{
            "geoname_id": 1806260,
            "names": {
                "en": "Jiangsu",
                "fr": "Province de Jiangsu",
                "zh-CN": "江苏省"
            },
            "iso_code": "32"
        }
    ],
    "country": {
        "geoname_id": 1814991,
        "names": {
            "en": "China",
            "ru": "Китай",
            "fr": "Chine",
            "pt-BR": "China",
            "zh-CN": "中国",
            "es": "China",
            "de": "China",
            "ja": "中国"
        },
        "iso_code": "CN"
    },
    "registered_country": {
        "geoname_id": 1814991,
        "names": {
            "en": "China",
            "ru": "Китай",
            "fr": "Chine",
            "pt-BR": "China",
            "zh-CN": "中国",
            "es": "China",
            "de": "China",
            "ja": "中国"
        },
        "iso_code": "CN"
    },
    "location": {
        "time_zone": "Asia\/Shanghai",
        "longitude": 118.7778,
        "accuracy_radius": 50,
        "latitude": 32.0617
    },
    "continent": {
        "geoname_id": 6255147,
        "names": {
            "en": "Asia",
            "ru": "Азия",
            "fr": "Asie",
            "pt-BR": "Ásia",
            "zh-CN": "亚洲",
            "es": "Asia",
            "de": "Asien",
            "ja": "アジア"
        },
        "code": "AS"
    }
}
node name: city, value: {
    "geoname_id": 1799962,
    "names": {
        "en": "Nanjing",
        "ru": "Нанкин",
        "fr": "Nankin",
        "pt-BR": "Nanquim",
        "zh-CN": "南京",
        "es": "Nankín",
        "de": "Nanjing",
        "ja": "南京市"
    }
}

References

Bug Reports

Please report bugs by filing an issue with our GitHub issue tracker at https://github.com/anjia0532/lua-resty-maxminddb/issues

If the bug is casued by libmaxminddb tracker at https://github.com/maxmind/libmaxminddb/issues

Copyright and License

This module is licensed under the apache LICENSE-2.0 license.

Copyright 2017-now anjia ([email protected])

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].