Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind
3.0.0
Prefix Reserved
See the version list below for details.
dotnet add package Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind --version 3.0.0
NuGet\Install-Package Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind -Version 3.0.0
<PackageReference Include="Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind" Version="3.0.0" />
<PackageVersion Include="Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind" Version="3.0.0" />
<PackageReference Include="Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind" />
paket add Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind --version 3.0.0
#r "nuget: Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind, 3.0.0"
#:package Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind@3.0.0
#addin nuget:?package=Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind&version=3.0.0
#tool nuget:?package=Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind&version=3.0.0
Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind
Loads a whole MaxMind DB file, such as a GeoIP2, GeoLite2 or ASN database, into a lookup table. MaxMind's Reader walks
the file's search tree one bit at a time and decodes a record on every lookup. MaxMindDatabase.Load decodes every
record once and builds a longest-prefix-match lookup from the networks.
dotnet add package Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind
Or from the NuGet Package Manager console:
PM> NuGet\Install-Package Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind
using System.Net;
using Bitvantage.InternetProtocol.NetworkPrefixLookup;
var countries = MaxMindDatabase.Load<Dictionary<string, object>>("GeoLite2-Country.mmdb").Freeze();
if (countries.TryGetMatchValue(IPAddress.Parse("81.2.69.160"), out var record))
Console.WriteLine(((Dictionary<string, object>)record["country"])["iso_code"]); // GB
On an AMD Ryzen 7 7800X3D, with a database the size of a full routing table, 1,240,422 IPv4 and 413,309 IPv6 networks:
MaxMind Reader.Find |
Read-write lookup | Frozen lookup | |
|---|---|---|---|
| Time per lookup | 254 ns | 38 ns | 27 ns |
| Allocated per lookup | 344 bytes | Nothing | Nothing |
The lookup costs time to load and memory to hold. That database took 0.9 seconds to load and the read-write lookup held 225 MB, where the reader opens at once and maps the 19 MB file. The lookup pays off when an application looks up many addresses, such as a server that checks every request or a job that processes logs. For a few lookups, or where memory is tight, MaxMind's reader is the better choice.
MaxMind lookups map IPv4-mapped addresses such as ::ffff:81.2.69.160 to IPv4 by default, as MaxMind's reader does.
Set MaxMindLoadOptions.IncludeAliasedNetworks to also load the IPv4-compatible, 6to4 and Teredo aliases of MaxMind's
IPv6 databases, so that every address gets the answer that Reader.Find gives.
Load only databases you trust. A database's search tree can point many branches at one subtree, so a hostile file of a few hundred bytes can expand into millions of networks.
The lookups have the same members as the core package's lookups for System.Net.IPNetwork, including queries about
networks and frozen tables. The main README
describes them.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Bitvantage.InternetProtocol.NetworkPrefixLookup (>= 3.0.0)
- MaxMind.Db (>= 5.2.0)
-
net8.0
- Bitvantage.InternetProtocol.NetworkPrefixLookup (>= 3.0.0)
- MaxMind.Db (>= 5.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.