Crate ip_alloc_lookup

Crate ip_alloc_lookup 

Source
Expand description

Offline IP-to-country and region classification based on RIPE NCC data.

This crate provides a lightweight, allocation-based alternative to MaxMind-style GeoIP databases. Instead of city-level precision, it focuses on:

  • Country code (ISO-3166 alpha-2)
  • Coarse regional grouping (EU / non-EU, etc.)
  • Fully offline, deterministic lookups

§Data source

The database is built from RIPE NCC “delegated statistics” files, which list IPv4 and IPv6 address allocations by country. These files are:

  • Public
  • Regularly updated
  • Easy to parse and cache

By default, a preprocessed snapshot is embedded at compile time for zero-I/O runtime lookups.

§Design goals

  • No runtime network access required
  • Minimal memory usage
  • Fast lookups via binary search
  • Simple API suitable for policy decisions (e.g. GDPR / EU checks)

§Limitations

This crate does not attempt to provide:

  • City or ISP precision
  • User location inference
  • Dynamic routing awareness

It reflects allocation data, not actual physical location.

Structs§

DbStats
Summary counts for the database contents.
GeoInfo
Compact classification result for a single IP range.
GeoIpDb
Offline, in-memory lookup database for allocation-based IP classification.
IpRange
A single allocation block parsed from a RIPE delegated statistics file.

Functions§

parse_ripe_delegated
Parse RIPE NCC “delegated-*” statistics content into allocation ranges.