Skip to content

fix: bypass H5 geo-lock by forwarding the caller's real IP upstream - #16

Open
ndizeyedavid wants to merge 5 commits into
walterwhite-69:mainfrom
ndizeyedavid:fix/geo-lock-bypass
Open

fix: bypass H5 geo-lock by forwarding the caller's real IP upstream#16
ndizeyedavid wants to merge 5 commits into
walterwhite-69:mainfrom
ndizeyedavid:fix/geo-lock-bypass

Conversation

@ndizeyedavid

@ndizeyedavid ndizeyedavid commented Aug 9, 2026

Copy link
Copy Markdown

Summary

Fixes the H5-block / AWS geo-locking problem (#4) that stops this API from working when deployed on VPS/datacenter hosts (Railway, Render, DigitalOcean, etc.). Cloudflare/h5-api.aoneroom.com sees the datacenter's IP as non-residential and refuses responses.

What changed

  • Added _client_ip() => resolves the real caller IP from proacy headers (X-Forwarded-For => X-Real-IP => socket peer), with a null-safe fallback.
  • Added _geo_headers() => maps that IP to X-Forwarded-For / X-Real-IP so the upstream CDN sees a residential client instead of the VPS.
  • _make_request() now merges those headers into every upstream call.
  • Threaded the client IP through all routes in main.py (the file Procfile, railway.json and vercel.json actually run): /home, /movies, /tv-series, /animation, /search, /search/suggest, /detail, /api/stream/{id} and captions.
  • Applied the same fix to api.py (the v2.2.0 direct-stream server), including the STREAM_BASE play requests on h5.aoneroom.com.
  • No breaking changes: request is injected by FastAPI, all URL params keep their existing names/defaults, and existing clients are untouched.

Why this works

The blocker is IP-based. The play/video requests carry a full browser fingerprint already; the missing piece was the source IP. Forwarding the caller's real IP makes the CDN believe the video request comes from the same residential client that loaded the site. so AWS stops geo-blocking requests coming from servers.

Testing

  • python -m py_compile main.py api.py => passes. - Formatting follows PEP 8.
  • 鈿狅笍 Note: python verify.py currently targets routes that the current main.py does not implement (/home/trending, /home/banner, /home/sections, /ranking) - this mismatch predates the PR, so the script cannot pass against the live server as-is. Happy to align if need tho...
    verify.py with the actual route set in a follow-up PR if useful.

Files touched

  • main.py
  • api.py

Resolve the caller's real IP from proxy headers (X-Forwarded-For, X-Real-IP, socket peer) and forward it upstream via _geo_headers so AWS/CDN geo-locks see a residential client instead of the datacenter IP. Extend _make_request to merge those headers into every upstream call.
Wire the Request object into /home, /movies, /tv-series, /animation, /search, /search/suggest and /detail routes so every upstream call carries the caller's real IP via _geo_headers. This keeps the API usable from datacenter/VPS hosts behind AWS geo-locks.
The play request to the netfilm.world CDN is the one AWS actually geo-locks, so forward the caller's real IP there too (X-Forwarded-For/X-Real-IP) alongside the browser-fingerprint headers, and carry it through the domain + caption lookups as well.
The v2.2.0 aoneroom direct-stream server gets the same treatment: _client_ip/_geo_headers helpers, client-IP propagation through every route, and the real IP forwarded on the stream/caption play requests so the AWS geo-lock no longer blocks VPS deployments.
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.

1 participant