How masterking32/masterhttprelayvpn works
1. What this system is
- MasterHttpRelayVPN is a local proxy gateway that sits on the user machine and forwards browser traffic through a Google Apps Script relay using domain fronting.
- The core trust boundary is: browser/device → local proxy → Google-facing relay → destination site.
- An optional exit node can be added later for sites that block Google egress IPs.
2. Primary runtime entry points
- main.py is the Python application entry point.
- start.sh and start.bat are the user-facing launchers; they create/install the environment, load config, and start the proxy.
- Dockerfile and docker-compose.yml package the same runtime for containerized deployment.
- config.example.json indicates the app is configuration-driven, with a generated config.json used at runtime.
3. Local proxy subsystem
- src/proxy/ is the local network-facing layer.
- It exposes both HTTP proxy and SOCKS5 endpoints, matching the quick-start ports in the README (8085 and 1080).
- This layer accepts browser/client connections, normalizes requests, and routes them into the relay path.
4. MITM and certificate handling
- src/proxy/mitm.py and src/core/cert_installer.py implement the TLS interception path.
- The proxy installs a local CA certificate so it can decrypt HTTPS traffic, inspect or modify it, then re-encrypt for the upstream path.
- This is a major security boundary: the browser trusts the local CA, while the proxy can inspect content before forwarding.
5. Relay forwarding layer
- src/relay/ is the outbound transport subsystem that connects the local proxy to the remote relay service.
- domain_fronter.py, fronting_support.py, h2_transport.py, http_reader.py, and relay_response.py together suggest:
- request shaping for fronting,
- HTTP/2-based upstream transport,
- response parsing/relay reconstruction.
- This layer is where the project hides the true destination behind a Google-looking connection.
6. Remote relay deployment on Google Apps Script
- apps_script/Code.gs is the main remote relay endpoint deployed as a Google Web App.
- The README shows the relay is authenticated with a shared secret (AUTH_KEY) and deployed under a Google account.
- apps_script/cloudflare_worker.js and apps_script/deno_deploy.ts indicate alternative relay/bridge deployments for environments outside Apps Script.
7. Optional exit-node extension
- apps_script/vps_exit_node.py and apps_script/setup_vps_exit_node.sh support a separate exit node path.
- The docs and README describe this as an optional layer for destinations that reject Google egress IPs.
- The exit-node architecture introduces another external boundary: Google relay → exit node (Cloudflare Worker or VPS) → target site.
8. Core utilities used across layers
- src/core/ contains shared helpers that support the proxy and relay stack:
- adblock.py for filtering,
- codec.py for encoding/decoding payloads,
- google_ip_scanner.py for Google IP selection/validation,
- lan_utils.py for LAN sharing,
- logging_utils.py for runtime diagnostics,
- constants.py for shared settings.
- src/core/google_ip_scanner.py and the relay modules suggest the system may actively choose usable Google-facing endpoints.
9. Traffic policy and filtering
- src/core/adblock.py and the README’s ad-block references show that request filtering is built into the proxy path.
- This means traffic is not just forwarded; some requests can be blocked or rewritten before reaching the relay.
- In an architecture diagram, this sits on the local proxy ingress path before upstream relay dispatch.
10. Configuration, security, and deployment boundaries
- docs/CONFIGURATION.md, docs/SECURITY.md, and docs/ARCHITECTURE.md define operational rules rather than code paths, but they matter architecturally.
- The key secrets/boundaries are auth_key, config.json, and the installed CA certificate directory.
- The README explicitly warns not to share the config, CA, or valid exit-node credentials together, which reflects the security model of the system.
11. Network clients and sharing
- The proxy is primarily intended for a browser, but LAN sharing is supported via docs/LAN_SHARING.md and src/core/lan_utils.py.
- This means the local proxy can be reused by other devices on the same network, turning the host into a small proxy appliance.
- The diagram should therefore include optional downstream clients beyond the local browser.
12. Tests and validation
- tests/ covers focused units around adblock, codec, fronting support, and proxy support.
- scripts/benchmark_transport.py suggests transport-layer performance comparison or tuning.
- These are supporting tools, not runtime subsystems, but they show where the critical seams are: filtering, encoding, fronting, and proxy behavior.
13. End-to-end data flow
- The typical path is:
- browser/device sends HTTP(S) traffic to the local proxy,
- local proxy performs MITM and policy checks,
- relay layer packages the request for domain fronting,
- Google Apps Script relay forwards it onward,
- optional exit node may be used for difficult destinations,
- response returns through the same chain to the browser.
- This is the main flow to emphasize in any architecture diagram.
14. Technology profile
- Core runtime is Python for the local proxy and relay client.
- The relay endpoint is Google Apps Script JavaScript.
- Optional deployment targets include Cloudflare Workers, Deno Deploy, and VPS-based Python.
- The repo also includes Docker and CI workflows, so the project is designed to be portable across local, container, and cloud deployment models.
Main entry points: proxy_server.py Proxy server · __init__.py Relay client · Code.gs Apps Script · main.py Main app
Components 17
Local clients
User devices and downstream consumers of the local proxy.
- Browser · Primary browser traffic source.
- LAN peers · Other devices that can share the local proxy.
docs/LAN_SHARING.md
Local runtime
Python entrypoints and the on-machine proxy stack.
- Launchers · User-facing startup scripts and packaging entrypoints.
start.sh - Main app · Main Python application entrypoint.
main.py - Proxy server · Network-facing HTTP proxy and SOCKS5 listener.
src/proxy/proxy_server.py - SOCKS5 · SOCKS5 access path for client traffic.
src/proxy/socks5.py - MITM · HTTPS interception and re-encryption boundary.
src/proxy/mitm.py
Relay transport
Outbound packaging and upstream forwarding through fronting.
- Relay client · Coordinates outbound relay requests.
src/relay/__init__.py - Domain fronting · Shapes requests to hide the true destination.
src/relay/domain_fronter.py - HTTP/2 transport · HTTP/2-based upstream transport to the relay.
src/relay/h2_transport.py - Relay parser · Reads and reconstructs relay responses.
src/relay/http_reader.py
Remote relay
Google Apps Script relay and alternate deployment targets.
- Apps Script · Google Apps Script web app relay endpoint.
apps_script/Code.gs - Alt relay · Alternative relay/bridge implementation for other runtimes.
apps_script/cloudflare_worker.js
Optional exit
Extra egress path for destinations that reject Google IPs.
- Exit node · Secondary egress path for blocked destinations.
apps_script/vps_exit_node.py
Shared core
Cross-cutting helpers for policy, security, and runtime support.
- Cert install · Installs the local CA certificate used by MITM.
src/core/cert_installer.py - Policy filter · Ad blocking and request filtering on ingress.
src/core/adblock.py - Core utils · Shared constants, logging, encoding, LAN, and Google IP helpers.
src/core/constants.py
Connections 19
- Browser → Proxy server: HTTP(S) · Browser traffic enters the local proxy.
- LAN peers → Proxy server: shared proxy · LAN clients can reuse the same local proxy.
- Launchers → Main app: starts · Launchers install/load config and start the runtime.
- Main app → Proxy server: boots · Main app initializes the proxy subsystem.
- Proxy server → SOCKS5: SOCKS5 · The proxy exposes a SOCKS5 endpoint.
- Proxy server → MITM: MITM · HTTPS traffic is intercepted for inspection and forwarding.
- MITM → Cert install: trusts CA · MITM depends on the locally installed certificate authority.
- Proxy server → Policy filter: filters · Ingress requests are filtered before upstream dispatch.
- Proxy server → Relay client: forwards · Accepted traffic is handed to the relay client.
- Relay client → Domain fronting: shapes · Relay requests are prepared for domain fronting.
- Relay client → HTTP/2 transport: transports · Outbound relay traffic uses HTTP/2 transport.
- Domain fronting → Apps Script: fronts to · Fronted requests target the Google Apps Script relay.
- HTTP/2 transport → Apps Script: upstream · Transport reaches the remote relay service.
- Apps Script → Relay parser: returns · Responses are read and reconstructed on the way back.
- Relay parser → Proxy server: response · Relay responses flow back to the local proxy.
- Apps Script → Exit node: optional egress · Some deployments chain to an exit node for final delivery.
- Exit node → Alt relay: alt bridge · Exit-node style routing can also be hosted on alternate deployments.
- Proxy server → Core utils: shared core · Proxy behavior relies on shared helpers and runtime utilities.
- Relay client → Core utils: shared core · Relay client reuses codec, logging, IP selection, and constants.