Database

Handles opening, reading and accessing the MaxMind GeoIP database

Constructors

this
this(string filename)

Opens the database located at $filename on the system.

Members

Functions

findMetadataBlockStart
ulong findMetadataBlockStart()

Scans the database file from the end to locate the metadata block (Yes, this is how MaxMind says to do)

getNodeAt
DatabaseNode getNodeAt(ulong position)

Returns a database node at $position (in node count)

lookup
DataNode lookup(string address)

Looks up any IP address in the database by delegating the search to the appropriate function

lookupV4
DataNode lookupV4(string address)
DataNode lookupV4(ubyte[4] address)

Looks up an IPv4 address in the database, or return null if the record is not found.

lookupV6
DataNode lookupV6(ubyte[16] address)

Looks up an IPv6 address in the database, or return null if the record is not found.

lookupV6
DataNode lookupV6(string address)

Looks up an IPv6 address in the database, or return null if the record is not found.

lookup_impl
DataNode lookup_impl(ubyte[] address)

Internal implementation of the database search algorithm: takes the address as an array and searches the tree.

readMetadata
void readMetadata()

Reads the database metadata from the file and sets it in the instance

Properties

metadata
const(Metadata) metadata [@property getter]

Read-only accessor for the metadata

Variables

dbfile
MmFile dbfile;

The memory-mapped database file for easy and fast access

Meta