Skip to content

Erlang application for working with MaxMind geoip2 (.mmdb) databases

License

Notifications You must be signed in to change notification settings

SemanticSugar/geodata2

This branch is 56 commits ahead of altenmueller/geodata2:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

9cf6159 · Aug 15, 2024

History

63 Commits
Mar 23, 2021
Aug 15, 2024
Aug 15, 2024
Aug 15, 2024
Apr 22, 2020
Apr 7, 2022
Nov 9, 2022
Dec 9, 2014
Nov 16, 2020
Sep 10, 2020
Feb 22, 2021
Apr 2, 2024
Jan 26, 2021

Repository files navigation

Erlang OTP application for handling MaxMind(tm) Geoip2 (.mmdb) files.

This is a forked branch of altenmueller/geodata2, which uses a shared ETS table to hold the database state rather than a cluster of workers.
This was done to improve performance.

Features:

  • Supports all types (hopefully) of bases in .mmdb format, both IPv4 and IPv6 ones.
  • Safe from binary reference leakage, binary parts are getting copied.
  • R18 compatible.
  • OTP22 compatible.
  • Uses rebar3.

The app accepts IPs in {B3:8, B2:8, B1:8, B0:8}, {W7:16, W6:16, W5:16, W4:16, W3:16, W2:16, W1:16, W0:16}, string, binary string, and big-endian dword formats.

Example:

Download and unzip GeoLite2-City.mmdb from MaxMind site and put the databases in the priv/ dir.

1> geodata2:start().
ok
3> geodata2:lookup({94, 75, 242, 11}).
{ok,[{<<"registered_country">>,
      [{<<"names">>,
        [{<<"zh-CN">>,<<232,141,183,229,133,176>>},
         {<<"ru">>,
          <<208,157,208,184,208,180,208,181,209,128,208,187,208,
            176,208,189,208,...>>},
         {<<"pt-BR">>,<<"Holanda">>},
    ...
       {<<"geoname_id">>,6255148},
       {<<"code">>,<<"EU">>}]}]}
8> geodata2:lookup({127, 0, 0, 1}).
not_found
9> geodata2:lookup({127, 0, 0, 1, 1}).
{error,format}

A MaxMind repo with a number of test bases: MaxMind-DB

This application uses some bits and pieces from egeoip

About

Erlang application for working with MaxMind geoip2 (.mmdb) databases

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Erlang 89.1%
  • Shell 8.4%
  • Makefile 2.5%