Skip to content

Block site access from Mountain View (DB-IP, no key required) - #35

Merged
lbesecker195 merged 2 commits into
mainfrom
feat/geo-block-mountain-view
Sep 19, 2026
Merged

lbesecker195 merged 2 commits into
mainfrom
feat/geo-block-mountain-view

Conversation

@lbesecker195

Copy link
Copy Markdown
Owner

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

IP Location Result
8.8.8.8 Mountain View, CA 403, halted
1.1.1.1 Sydney allowed
93.184.216.34 London allowed
127.0.0.1 loopback allowed

85 tests pass.

Two silent traps this avoids

  1. The databases spell a subdivision differently. MaxMind records "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.
  2. mix test would have pulled 57MB every run. The rule is empty in :test; the plug's tests inject a database response instead.

Fail-open matrix

Condition Result
No database downloaded yet allowed
Lookup error / unknown IP allowed
Loopback, private, link-local allowed
Confident match on a blocked city 403

A geo database that fails to download must never take the site off the air, so only a positive match blocks.

Known costs

  • ~179MB resident once the database loads — measured, not estimated.
  • May cost search visibility. 8.8.8.8 resolving to Mountain View is the tell: some Googlebot addresses geolocate there, so this can block part of the crawl. Nothing exempts crawlers.
  • City-level geo-IP is ~60–80% accurate within 50km; VPN traffic evades it.
  • The DB-IP credit in the footer is a CC BY 4.0 licence condition.

Pages affected:

🤖 Generated with Claude Code

Logan Besecker and others added 2 commits September 19, 2026 06:39
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>
@lbesecker195
lbesecker195 merged commit a27d28e into main Sep 19, 2026
4 checks passed
@lbesecker195
lbesecker195 deleted the feat/geo-block-mountain-view branch September 19, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Block site access from Mountain View by IP geolocation

1 participant