Runlight.Mmdb (runlight v0.1.0)

Copy Markdown View Source

A reader for MaxMind DB files (the MMDB format that MaxMind's GeoLite2 and DB-IP's free databases use), in plain Elixir so location needs no library. It answers what the TypeScript server's mmdb-lib answers: the record for an address, maps with string keys, or nil when the address is not in the database.

Format: https://maxmind.github.io/MaxMind-DB/

Summary

Functions

The record for an address, or nil. Raises ArgumentError for text that is not an IP address.

A database from its bytes. Raises ArgumentError when it is not one.

A database read from a file.

Types

t()

@type t() :: %Runlight.Mmdb{
  bytes: term(),
  data_start: term(),
  ipv4_start: term(),
  metadata: term(),
  node_bytes: term(),
  node_count: term(),
  record_size: term()
}

Functions

get(db, ip)

@spec get(t(), String.t()) :: term()

The record for an address, or nil. Raises ArgumentError for text that is not an IP address.

new(bytes)

@spec new(binary()) :: t()

A database from its bytes. Raises ArgumentError when it is not one.

open(path)

@spec open(Path.t()) :: t()

A database read from a file.