MaxMind.Db 4.1.0

Prefix Reserved
dotnet add package MaxMind.Db --version 4.1.0                
NuGet\Install-Package MaxMind.Db -Version 4.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MaxMind.Db" Version="4.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MaxMind.Db --version 4.1.0                
#r "nuget: MaxMind.Db, 4.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MaxMind.Db as a Cake Addin
#addin nuget:?package=MaxMind.Db&version=4.1.0

// Install MaxMind.Db as a Cake Tool
#tool nuget:?package=MaxMind.Db&version=4.1.0                

MaxMind DB Reader

NuGet API Docs

Description

This is the .NET API for reading MaxMind DB files. MaxMind DB is a binary file format that stores data indexed by IP address subnets (IPv4 or IPv6).

Installation

NuGet

We recommend installing this library with NuGet. To do this, type the following into the Visual Studio Package Manager Console:

install-package MaxMind.Db

Usage

Note: For accessing MaxMind GeoIP2 databases, we generally recommend using the GeoIP2 .NET API rather than using this package directly.

To use the API, you must first create a Reader object. The constructor for the reader object takes a string with the path to the MaxMind DB file. Optionally you may pass a second parameter with a FileAccessMode enum with the value MemoryMapped or Memory. The default mode is MemoryMapped, which maps the file to virtual memory. This often provides performance comparable to loading the file into real memory with the Memory mode while using significantly less memory.

To look up an IP address, pass a System.Net.IPAddress object to the Find<T> method on Reader. This method will return the result as type T. T may either be a generic collection or a class using the [MaxMind.Db.Constructor] attribute to declare which constructor to use during deserialization and the [MaxMind.Db.Parameter("name")] to map the database key name to a particular constructor parameter.

We recommend reusing the Reader object rather than creating a new one for each lookup. The creation of this object is relatively expensive as it must read in metadata for the file.

Example Decoding to a Dictionary


using (var reader = new Reader("GeoIP2-City.mmdb"))
{
    var ip = IPAddress.Parse("24.24.24.24");
    var data = reader.Find<Dictionary<string, object>>(ip);
    ...
}

Example Decoding to a Model Class

using MaxMind.Db;
using System.Net;

namespace MyCode
{
    public class Asn
    {
        [Constructor]
        public AsnResponse(
            // The Parameter attribute tells the reader to map the database
            // key to the specified constructor parameter.
            [Parameter("autonomous_system_number")] long? autonomousSystemNumber,
            [Parameter("autonomous_system_organization")] string autonomousSystemOrganization,

            // The Inject attribute allows you to inject arbitrary values
            // when deserializing.
            [Inject("ip_address")] IPAddress ipAddress),

            // The Network attribute tells the reader to set the constructor
            // parameter to be the network associated with the record in the
            // database.
            [Network] Network network
        {
          ...
        }

        ...
    }


    public class Program
    {
        private static void Main(string[] args)
        {
            using (var reader = new Reader("GeoLite2-ASN.mmdb"))
            {
                var ip = IPAddress.Parse("24.24.24.24");
                var injectables = new InjectableValues();
                injectables.AddValue("ip_address", ip);
                var data = reader.Find<Asn>(ip, injectables);
                ...
            }
        }
    }
}

Multi-Threaded Use

This API fully supports use in multi-threaded applications. In such applications, we suggest creating one Reader object and sharing that among threads.

Format

The MaxMind DB format is an open format for quickly mapping IP addresses to records. See the specification for more information on the format.

Bug Tracker

Please report all issues with this code using the GitHub issue tracker.

If you are having an issue with a MaxMind database or service that is not specific to this reader, please contact MaxMind support.

Contributing

Patches and pull requests are encouraged. Please include unit tests whenever possible.

Versioning

The MaxMind DB Reader API uses Semantic Versioning.

This software is Copyright (c) 2013-2022 by MaxMind, Inc.

This is free software, licensed under the Apache License, Version 2.0.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (10)

Showing the top 5 NuGet packages that depend on MaxMind.Db:

Package Downloads
MaxMind.GeoIP2

MaxMind GeoIP2 Database Reader and Web Service Client

Dynamicweb.Admin

Package Description

Dynamicweb.Tracking.Web

Providers and dependencies for web tracking

NopCommerce.Core

Contains the core assemblies needed to run nopcommerce. This package only contains assemblies and can be used for package development.

MoarUtils

Useful utilities to more efficient .NET development #OnTheShouldersOfGiants

GitHub repositories (9)

Showing the top 5 popular GitHub repositories that depend on MaxMind.Db:

Repository Stars
smartstore/SmartStoreNET
Open Source ASP.NET MVC Enterprise eCommerce Shopping Cart Solution
Archeb/opentrace
A cross-platform GUI wrapper for NextTrace. Bringing you the familiar traceroute experience. OpenTrace 是 NextTrace 的跨平台 GUI 界面,带来您熟悉但更强大的用户体验。
smartstore/Smartstore
A modular, scalable and ultra-fast open-source all-in-one eCommerce platform built on ASP.NET Core 7
moom825/xeno-rat
Xeno-RAT is an open-source remote access tool (RAT) developed in C#, providing a comprehensive set of features for remote system management. Has features such as HVNC, live microphone, reverse proxy, and much much more!
wokhan/WFN
Windows Firewall Notifier extends the default Windows embedded firewall by allowing to handle and notify about outgoing connections, offers real time connections monitoring, connections map, bandwidth usage monitoring and more...
Version Downloads Last updated
4.1.0 1,763,242 12/5/2023
4.0.0 3,497,234 2/3/2022
3.0.0 2,430,232 11/16/2020
2.6.1 3,302,840 12/6/2019
2.6.0 1,437 12/6/2019
2.5.0 6,435 11/21/2019
2.4.0 3,529,332 4/11/2018
2.3.0 1,572,101 10/27/2017
2.2.0 256,758 5/8/2017
2.1.3 624,694 11/22/2016
2.1.2 207,001 8/8/2016
2.1.1 6,278 8/1/2016
2.1.1-beta1 4,138 6/1/2016
2.1.0-beta4 1,890 6/1/2016
2.1.0-beta3 3,351 5/12/2016
2.1.0-beta2 2,004 5/10/2016
2.1.0-beta1 1,696 5/10/2016
2.0.0 655,850 4/15/2016
2.0.0-beta3 1,944 3/24/2016
2.0.0-beta2 8,452 1/29/2016
2.0.0-beta1 3,125 1/18/2016
1.2.0 172,907 9/23/2015
1.2.0-beta1 2,885 9/8/2015
1.1.0 53,374 7/21/2015
1.1.0-beta1 2,954 6/30/2015
1.0.1 207,174 5/19/2015
1.0.0 285,814 9/29/2014
0.3.0 4,870 9/24/2014
0.2.3 61,309 4/9/2014
0.2.2 41,448 12/24/2013
0.2.1 15,901 11/15/2013
0.2.0 3,792 10/25/2013
0.1.0 4,662 10/22/2013