Skip to content

Commit 2ac8cb4

Browse files
seanthegeekclaude
andauthored
Replace DB-IP Country Lite with IPinfo Lite (9.8.0) (#711)
Switch the bundled IP-to-country database from DB-IP Country Lite to IPinfo Lite for greater lookup accuracy. The download URL, cached filename, and packaged module path all move from dbip/dbip-country-lite.mmdb to ipinfo/ipinfo_lite.mmdb. IPinfo Lite uses a different MMDB schema (flat country_code) that is incompatible with geoip2's Reader.country() helper, so get_ip_address_country() now uses maxminddb directly and handles both the IPinfo schema and the MaxMind/DBIP nested country.iso_code schema so users who drop in their own MMDB from any of these providers continue to work. Drop the geoip2 dependency (it was only used for the incompatible helper) and add maxminddb as a direct dependency — it was already installed transitively through geoip2. Callers that imported parsedmarc.resources.dbip directly need to switch to parsedmarc.resources.ipinfo. Old parsedmarc versions downloading from the dbip/ GitHub raw URL will 404 and fall back to their bundled copy — this is the documented behavior of load_ip_db(). Co-authored-by: Sean Whalen <seanthegeek@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 67f46a7 commit 2ac8cb4

12 files changed

Lines changed: 76 additions & 52 deletions

File tree

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Changelog
22

3+
## 9.8.0
4+
5+
### Changes
6+
7+
- Replaced the bundled DB-IP Country Lite database with the [IPinfo Lite] database (`parsedmarc/resources/ipinfo/ipinfo_lite.mmdb`, under the [Creative Commons Attribution-ShareAlike 4.0 License][cc-by-sa-4]) for greater IP-to-country lookup accuracy. The download URL / cached filename / packaged module path have all moved from `dbip/dbip-country-lite.mmdb` to `ipinfo/ipinfo_lite.mmdb`.
8+
- `get_ip_address_country()` now reads MMDBs with `maxminddb` directly and handles both schemas — the IPinfo flat-top-level `country_code` field and the MaxMind/DBIP nested `country.iso_code` field — so users who drop in their own MMDB from any of these providers continue to work. The in-disk search list for user-supplied files still includes `ipinfo_lite.mmdb`, `GeoLite2-Country.mmdb`, and `dbip-country-lite*.mmdb`.
9+
- Dropped the `geoip2` dependency (its only use was the `.country()` helper, which is incompatible with the IPinfo schema). Added `maxminddb` as a direct dependency — it was already installed transitively through `geoip2`, so this is a no-op for most environments.
10+
11+
### Upgrade notes
12+
13+
- Callers that imported `parsedmarc.resources.dbip` directly need to switch to `parsedmarc.resources.ipinfo`. The `parsedmarc.resources.dbip` module has been removed.
14+
- Callers that imported `geoip2` only because `parsedmarc` depended on it will need to add it to their own requirements. `parsedmarc` itself no longer depends on `geoip2`.
15+
- The auto-update download URL used by previous parsedmarc versions (`.../dbip/dbip-country-lite.mmdb`) is no longer hosted on `master`; those versions will fail to download and fall back to their bundled copy, which is the documented behavior of `load_ip_db()`.
16+
17+
[IPinfo Lite]: https://ipinfo.io/lite
18+
[cc-by-sa-4]: https://creativecommons.org/licenses/by-sa/4.0/deed.en
19+
320
## 9.7.1
421

522
### Changes

docs/source/installation.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,20 @@ least:
4444
### geoipupdate setup
4545

4646
:::{note}
47-
Starting in `parsedmarc` 7.1.0, a static copy of the
48-
[IP to Country Lite database] from IPDB is distributed with
49-
`parsedmarc`, under the terms of the
50-
[Creative Commons Attribution 4.0 International License].
47+
Starting in `parsedmarc` 9.8.0, a static copy of the
48+
[IPinfo Lite] database is distributed with `parsedmarc`, under the
49+
terms of the [Creative Commons Attribution-ShareAlike 4.0 License],
5150
as a fallback if the [MaxMind GeoLite2 Country database] is not
52-
installed.
51+
installed. Prior versions bundled the DB-IP Country Lite database
52+
instead; both share the same MMDB format, so users who have installed
53+
either (or a MaxMind GeoLite2) database locally will continue to work
54+
without changes.
5355

54-
Starting in `parsedmarc` 9.6.0, the bundled DB-IP database is
55-
automatically updated at startup by downloading the latest copy from
56-
GitHub, unless the `offline` flag is set. The database is cached
57-
locally and refreshed on each run (or on `SIGHUP` in watch mode).
58-
If the download fails, a previously cached copy or the bundled
59-
database is used as a fallback.
56+
The bundled database is automatically updated at startup by downloading
57+
the latest copy from GitHub, unless the `offline` flag is set. The
58+
database is cached locally and refreshed on each run (or on `SIGHUP`
59+
in watch mode). If the download fails, a previously cached copy or the
60+
bundled database is used as a fallback.
6061

6162
The download URL can be overridden with the `ip_db_url` setting, and
6263
the location of a local database file can be overridden with the
@@ -203,7 +204,8 @@ sudo apt-get install libemail-outlook-message-perl
203204
[Component "contrib"]: https://wiki.debian.org/SourcesList#Component
204205
[geoipupdate]: https://github.com/maxmind/geoipupdate
205206
[geoipupdate releases page on github]: https://github.com/maxmind/geoipupdate/releases
206-
[ip to country lite database]: https://db-ip.com/db/download/ip-to-country-lite
207+
[ipinfo lite]: https://ipinfo.io/lite
208+
[creative commons attribution-sharealike 4.0 license]: https://creativecommons.org/licenses/by-sa/4.0/deed.en
207209
[license keys]: https://www.maxmind.com/en/accounts/current/license-key
208210
[maxmind geoipupdate page]: https://dev.maxmind.com/geoip/updating-databases/
209211
[maxmind geolite2 country database]: https://dev.maxmind.com/geoip/geolite2-free-geolocation-data

docs/source/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ The full set of configuration options are:
133133
- `forensic_json_filename` - str: filename for the forensic
134134
JSON output file
135135
- `ip_db_path` - str: An optional custom path to a MMDB file
136-
from MaxMind or DBIP
136+
from IPinfo, MaxMind, or DBIP
137137
- `ip_db_url` - str: Overrides the default download URL for the
138138
IP-to-country database (env var: `PARSEDMARC_GENERAL_IP_DB_URL`)
139139
- `offline` - bool: Do not use online queries for geolocation

parsedmarc/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def _parse_report_record(
317317
always_use_local_files (bool): Do not download files
318318
reverse_dns_map_path (str): Path to a reverse DNS map file
319319
reverse_dns_map_url (str): URL to a reverse DNS map file
320-
ip_db_path (str): Path to a MMDB file from MaxMind or DBIP
320+
ip_db_path (str): Path to a MMDB file from IPinfo, MaxMind, or DBIP
321321
offline (bool): Do not query online for geolocation or DNS
322322
nameservers (list): A list of one or more nameservers to use
323323
(Cloudflare's public DNS resolvers by default)
@@ -685,7 +685,7 @@ def parse_aggregate_report_xml(
685685
686686
Args:
687687
xml (str): A string of DMARC aggregate report XML
688-
ip_db_path (str): Path to a MMDB file from MaxMind or DBIP
688+
ip_db_path (str): Path to a MMDB file from IPinfo, MaxMind, or DBIP
689689
always_use_local_files (bool): Do not download files
690690
reverse_dns_map_path (str): Path to a reverse DNS map file
691691
reverse_dns_map_url (str): URL to a reverse DNS map file
@@ -1009,7 +1009,7 @@ def parse_aggregate_report_file(
10091009
always_use_local_files (bool): Do not download files
10101010
reverse_dns_map_path (str): Path to a reverse DNS map file
10111011
reverse_dns_map_url (str): URL to a reverse DNS map file
1012-
ip_db_path (str): Path to a MMDB file from MaxMind or DBIP
1012+
ip_db_path (str): Path to a MMDB file from IPinfo, MaxMind, or DBIP
10131013
nameservers (list): A list of one or more nameservers to use
10141014
(Cloudflare's public DNS resolvers by default)
10151015
dns_timeout (float): Sets the DNS timeout in seconds
@@ -1257,7 +1257,7 @@ def parse_forensic_report(
12571257
Args:
12581258
feedback_report (str): A message's feedback report as a string
12591259
sample (str): The RFC 822 headers or RFC 822 message sample
1260-
ip_db_path (str): Path to a MMDB file from MaxMind or DBIP
1260+
ip_db_path (str): Path to a MMDB file from IPinfo, MaxMind, or DBIP
12611261
always_use_local_files (bool): Do not download files
12621262
reverse_dns_map_path (str): Path to a reverse DNS map file
12631263
reverse_dns_map_url (str): URL to a reverse DNS map file
@@ -1493,7 +1493,7 @@ def parse_report_email(
14931493
14941494
Args:
14951495
input_: An emailed DMARC report in RFC 822 format, as bytes or a string
1496-
ip_db_path (str): Path to a MMDB file from MaxMind or DBIP
1496+
ip_db_path (str): Path to a MMDB file from IPinfo, MaxMind, or DBIP
14971497
always_use_local_files (bool): Do not download files
14981498
reverse_dns_map_path (str): Path to a reverse DNS map
14991499
reverse_dns_map_url (str): URL to a reverse DNS map
@@ -1715,7 +1715,7 @@ def parse_report_file(
17151715
or other transient errors
17161716
strip_attachment_payloads (bool): Remove attachment payloads from
17171717
forensic report results
1718-
ip_db_path (str): Path to a MMDB file from MaxMind or DBIP
1718+
ip_db_path (str): Path to a MMDB file from IPinfo, MaxMind, or DBIP
17191719
always_use_local_files (bool): Do not download files
17201720
reverse_dns_map_path (str): Path to a reverse DNS map
17211721
reverse_dns_map_url (str): URL to a reverse DNS map
@@ -1814,7 +1814,7 @@ def get_dmarc_reports_from_mbox(
18141814
always_use_local_files (bool): Do not download files
18151815
reverse_dns_map_path (str): Path to a reverse DNS map file
18161816
reverse_dns_map_url (str): URL to a reverse DNS map file
1817-
ip_db_path (str): Path to a MMDB file from MaxMind or DBIP
1817+
ip_db_path (str): Path to a MMDB file from IPinfo, MaxMind, or DBIP
18181818
offline (bool): Do not make online queries for geolocation or DNS
18191819
normalize_timespan_threshold_hours (float): Normalize timespans beyond this
18201820
@@ -1907,7 +1907,7 @@ def get_dmarc_reports_from_mailbox(
19071907
archive_folder (str): The folder to move processed mail to
19081908
delete (bool): Delete messages after processing them
19091909
test (bool): Do not move or delete messages after processing them
1910-
ip_db_path (str): Path to a MMDB file from MaxMind or DBIP
1910+
ip_db_path (str): Path to a MMDB file from IPinfo, MaxMind, or DBIP
19111911
always_use_local_files (bool): Do not download files
19121912
reverse_dns_map_path (str): Path to a reverse DNS map file
19131913
reverse_dns_map_url (str): URL to a reverse DNS map file
@@ -2249,7 +2249,7 @@ def watch_inbox(
22492249
test (bool): Do not move or delete messages after processing them
22502250
check_timeout (int): Number of seconds to wait for a IMAP IDLE response
22512251
or the number of seconds until the next mail check
2252-
ip_db_path (str): Path to a MMDB file from MaxMind or DBIP
2252+
ip_db_path (str): Path to a MMDB file from IPinfo, MaxMind, or DBIP
22532253
always_use_local_files (bool): Do not download files
22542254
reverse_dns_map_path (str): Path to a reverse DNS map file
22552255
reverse_dns_map_url (str): URL to a reverse DNS map file

parsedmarc/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "9.7.1"
1+
__version__ = "9.8.0"
22

33
USER_AGENT = f"parsedmarc/{__version__}"
44

parsedmarc/resources/dbip/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.
-8.02 MB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# About
2+
3+
`ipinfo_lite.mmdb` is provided by [IPinfo][ipinfo] under the
4+
[Creative CommonsAttribution-ShareAlike 4.0 License][cc].
5+
6+
[ipinfo]: https://ipinfo.io/lite
7+
[cc]: https://creativecommons.org/licenses/by-sa/4.0/deed.en
40.2 MB
Binary file not shown.

0 commit comments

Comments
 (0)