feat(mmdb): stdlib-only MaxMind DB reader - #2
Merged
Merged
Conversation
The read companion to the mmdb-write command. mmdb-write depends on the third-party maxmind/mmdbwriter and is isolated in its own module for that reason; the reader is implemented from scratch on the standard library and lives in the root package, so downstream consumers can read cidr-produced databases (ASN, country, or any custom schema) through a first-party API with ZERO third-party transitive dependencies — the root module's go.mod stays empty. - OpenMMDB / OpenMMDBBytes / Lookup / Metadata / Close. - Full MaxMind DB v2 format: metadata parse, 24/28/32-bit search-tree records, IPv4-in-IPv6 (::/96) lookups, and the complete data decoder (string, uint16/32/64, int32, double, float, bytes, bool, map, array, uint128, and data-section pointers). - Tests over mmdb-write-produced fixtures: ASN across all three record sizes, nested-map Country records, deduped records resolved via data-section pointers, IPv4/IPv6/not-found, and open-error paths. Fixtures are small and committed (the stdlib-only root can't synthesize MMDBs in-test the way the writer module does); .gitignore keeps large corpora ignored while tracking test-*.mmdb.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a from-scratch, standard-library-only MaxMind DB (.mmdb) reader to the root
cidrpackage — the read companion to themmdb-writecommand.mmdb-writeuses the third-partymaxmind/mmdbwriterand is isolated in its own module for that reason. The reader is implemented on the stdlib and lives in the root package, so downstream consumers (e.g. the planned aegis intel plane) can read cidr-produced databases through a first-party API with zero third-party transitive dependencies — the root module'sgo.modstays empty.API
OpenMMDB(path)/OpenMMDBBytes(b)/(*MMDB).Lookup(net.IP) (map[string]any, bool, error)/Metadata()/Close().Coverage (MaxMind DB v2 format)
::/96) lookups.mmdb-write-produced fixtures: ASN across all three record sizes, nested-map Country records, deduped records resolved through pointers, IPv4/IPv6/not-found, and open-error paths.Fixtures are small and committed because the stdlib-only root can't synthesize MMDBs in-test the way the writer module does;
.gitignorekeeps large corpora ignored while trackingtest-*.mmdb.go test -race ./...green; staticcheck clean; rootgo.modunchanged (still dependency-free).