Block site access from Mountain View (DB-IP, no key required) - #35
Merged
Merged
Conversation
Refuses requests whose IP geolocates to Mountain View, California, at the endpoint rather than in the router, so it covers the pages, the JSON API and the MCP endpoint alike. - Add locus, which downloads and refreshes the MaxMind city database itself, so there is no .mmdb to ship and no cron job to write - Run the check straight after ClientIP, so the lookup sees the real client rather than nginx, and before parsing or the session - Require every key in a rule to agree, since a city name alone is not unique - Fail open on every uncertain path: no licence key, no database, a lookup error, a private address, an unknown address - Inject the lookup in tests, so the matching rules and the 403 are covered without a licence key in CI Needs MAXMIND_LICENSE_KEY to do anything. Without it the loader never starts and the block is inert, which is the intended degradation. --- Pages affected: - [MCP Registry](https://ai.mcpharbor.dev/) — home page, covered by the endpoint-level block. - [Browse MCP servers](https://ai.mcpharbor.dev/servers) — the searchable catalogue. - [JSON API](https://ai.mcpharbor.dev/api/v0/servers) — machine-readable listings, blocked alongside the pages. - [Agent instructions](https://ai.mcpharbor.dev/llms.txt) — plain-text guide for agents. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The MaxMind source needed a licence key nobody had, so the block shipped inert. DB-IP publish a free city database under CC BY 4.0 with no account and no key, so the block is now live on a fresh deploy with nothing to register. - Default to DB-IP, resolved monthly, with a HEAD check falling back to last month so an unpublished file cannot leave the loader retrying a 404 - Keep MaxMind available behind GEOIP_SOURCE=maxmind for anyone who has a key - Let a rule list several spellings, because MaxMind writes the subdivision as "CA" and DB-IP as "California"; a rule naming one matched one database and failed silently against the other - Credit DB-IP in the footer, which their licence requires - Leave the rule empty in :test, so mix test does not download 57MB a run Verified against the real database: 8.8.8.8 (Mountain View) is refused with a 403, while Sydney, London and loopback pass. The loaded database costs about 179MB resident. --- Pages affected: - [MCP Registry](https://ai.mcpharbor.dev/) — home page, covered by the endpoint-level block. - [Browse MCP servers](https://ai.mcpharbor.dev/servers) — the searchable catalogue. - [JSON API](https://ai.mcpharbor.dev/api/v0/servers) — machine-readable listings, blocked alongside the pages. - [Agent instructions](https://ai.mcpharbor.dev/llms.txt) — plain-text guide for agents. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Closes #33. Replaces #34, which GitHub auto-closed when its base branch was deleted on merging #32; same branch, same commits, retargeted at
main.Refuses requests whose IP geolocates to Mountain View, California, at the endpoint rather than in the router, so it covers the pages, the JSON API and the MCP endpoint alike.
No licence key. Active on merge. The source is DB-IP's free city database (CC BY 4.0), which needs no account and no key. MaxMind stays available behind
GEOIP_SOURCE=maxmind.Verified against the real database
8.8.8.81.1.1.193.184.216.34127.0.0.185 tests pass.
Two silent traps this avoids
"CA", DB-IP records"California"under a different key. A rule naming one matches one database and gives no sign against the other — the block just never fires. Rule values accept a list of spellings; the shipped rule names both.mix testwould have pulled 57MB every run. The rule is empty in:test; the plug's tests inject a database response instead.Fail-open matrix
A geo database that fails to download must never take the site off the air, so only a positive match blocks.
Known costs
8.8.8.8resolving to Mountain View is the tell: some Googlebot addresses geolocate there, so this can block part of the crawl. Nothing exempts crawlers.Pages affected:
🤖 Generated with Claude Code