Skip to content

elixir-geolix/mmdb2_decoder

Repository files navigation

MMDB2 File Format Decoder

Test Module Version Hex Docs Total Downloads License Last Updated

Setup

Add the module as a dependency to your mix.exs file:

defp deps do
  [
    # ...
    {:mmdb2_decoder, "~> 3.0"},
    # ...
  ]
end

Usage

For more detailed examples and usage information please refer to the inline documentation of the MMDB2Decoder module.

Regular Flow

database = File.read!("/path/to/database.mmdb")
{:ok, meta, tree, data} = MMDB2Decoder.parse_database(database)

{:ok, ip} = :inet.parse_address(String.to_charlist("8.8.8.8"))

MMDB2Decoder.lookup(ip, meta, tree, data)

Direct Piping

"/path/to/database.mmdb"
|> File.read!()
|> MMDB2Decoder.parse_database()
|> MMDB2Decoder.pipe_lookup({8, 8, 8, 8})

Benchmark

Several (minimal) benchmark scripts are included as shown below:

$ mix bench.database
$ mix bench.lookup
$ mix bench.parse

Copyright and License

Copyright (c) 2017 Marc Neudert

Apache License, Version 2.0

License information about the supported MaxMind GeoIP2 Country, MaxMind GeoIP2 City and MaxMind GeoLite2 databases can be found on their respective sites.