How denuitt1/mhr-cfw works
1. What this repository is
This is a layered proxy/relay system for outbound web traffic. The local Python process acts as a client-side HTTP(S) proxy with MITM capabilities, then tunnels requests through Google-facing infrastructure and Cloudflare Worker relays to an external exit point.
2. Primary traffic path
The default path is: client/browser or system proxy → local relay on 127.0.0.1:8085 → Google/CDN fronting layer → Google Apps Script relay → Cloudflare Worker → destination site. The external observer is meant to see only benign-looking traffic to allowed front domains.
3. Local proxy subsystem
The core runtime lives in Python (main.py + src/). src/proxy_server.py is the network entrypoint, while src/mitm.py handles SSL interception so HTTPS traffic can be relayed. src/cert_installer.py supports installing the local CA certificate needed for MITM on the client device.
4. Request shaping and transport
src/codec.py and src/h2_transport.py are the payload/transport layer for moving requests through the relay chain, including HTTP/2-related behavior. This layer is the main boundary between normal client HTTP semantics and the encoded relay protocol carried to the remote endpoints.
5. Fronting and target selection
src/domain_fronter.py and src/google_ip_scanner.py support selecting or validating front domains and Google-facing endpoints used to hide the real destination. These pieces are what make the relay traffic look like requests to acceptable domains rather than direct outbound connections.
6. Local environment and binding utilities
src/lan_utils.py helps the proxy be reachable from other devices on the same LAN or from VMs, while src/constants.py centralizes runtime parameters. src/logging_utils.py provides consistent operational logging across the proxy pipeline.
7. Cloud-side relay boundary
The Google Apps Script deployment (deploy/gas/Code.gs) is the first remote relay endpoint. It authenticates requests using a shared secret, then forwards them to the Cloudflare Worker. This is a key trust boundary: the local proxy only talks to the GAS web app, not directly to the destination.
8. Cloudflare Worker exit layer
deploy/cloudflare-worker/worker.js is the Worker-side relay that receives requests from GAS and performs the actual outbound fetch(). In the base design, this is the exit point visible to destination sites, with the Worker’s egress IPs being the effective source address.
9. Optional stable-egress upstream forwarder
For sites that bind sessions or CAPTCHA tokens to a stable IP, there is an optional Node-based upstream forwarder in deploy/upstream_forwarder/. In that mode, the Worker sends outbound fetches to a VPS-hosted forwarder so the final exit IP becomes stable and under your control.
10. Configuration and runtime orchestration
config.example.json, run.sh, run.bat, and setup.py define startup and configuration for the local relay. The local process expects deployment-specific secrets/IDs for the GAS layer, and can also be configured with optional forwarder host routing.
11. Packaging and deployment artifacts
The repo includes Docker and Compose files for repeatable local or VPS deployment, plus a traefik.yml in the forwarder setup for TLS termination. These artifacts matter because the architecture spans desktop client, cloud relay, and optional VPS exit infrastructure.
12. High-level diagram boundaries
An accurate architecture diagram should show four distinct zones: the local client machine, Google Apps Script relay, Cloudflare Worker relay, and optional VPS forwarder. The important data flow is request encapsulation through the relays, certificate-based MITM on the client side, and optional upstream egress stabilization for CAPTCHA-sensitive destinations.
Main entry points: proxy_server.py Proxy server · worker.js Worker exit · upstream_forwarder.js Upstream forwarder · docker-compose.yml Compose
Components 18
External
User device and destination sites outside the repo
- Client · Browser or system traffic source
- Site · Final upstream destination seen by the relay chain
Local runtime
Python proxy and client-side helpers
- Python app · Top-level local process launcher
main.py - Proxy server · Local network entrypoint for intercepted requests
src/proxy_server.py - MITM · SSL interception for HTTPS relaying
src/mitm.py - Relay codec · Encodes requests for the relay chain
src/codec.py - H2 transport · HTTP/2-oriented relay transport
src/h2_transport.py - Fronting · Chooses benign-looking front domains and endpoints
src/domain_fronter.py - IP scan · Validates or selects Google-facing endpoints
src/google_ip_scanner.py - Cert install · Installs the local CA used for MITM
src/cert_installer.py - LAN helpers · Makes the proxy reachable across local networks or VMs
src/lan_utils.py - Config consts · Shared runtime parameters and defaults
src/constants.py - Logging · Shared operational logging helpers
src/logging_utils.py
Google relay
Apps Script boundary that forwards relay traffic
- GAS relay · Trusted cloud relay that forwards to the worker
deploy/gas/Code.gs
Worker exit
Cloudflare Worker and optional upstream egress
- Worker exit · Relay exit layer that performs outbound fetches
deploy/cloudflare-worker/worker.js - Upstream forwarder · Optional stable-egress forwarder for sensitive sessions
deploy/upstream_forwarder/upstream_forwarder.js
Connections 19
- Client → Proxy server: HTTP(S) · Client traffic enters the local proxy
- Python app → Proxy server: starts · Main process launches the proxy server
- Proxy server → MITM: intercepts · HTTPS traffic is decrypted and reissued
- Proxy server → Relay codec: encodes · Requests are packaged for relay transport
- Relay codec → H2 transport: rides on · Encoded payloads are carried over the transport layer
- Proxy server → Fronting: fronts through · Selects benign-looking front domains and endpoints
- Fronting → IP scan: validates · Fronting candidates are checked against Google-facing infrastructure
- Proxy server → Cert install: installs CA · Local trust setup for MITM interception
- Proxy server → LAN helpers: binds · Exposes the proxy to LAN or VM clients
- Proxy server → Config consts: reads · Runtime settings and defaults
- Proxy server → Logging: logs · Operational events are recorded consistently
- H2 transport → GAS relay: forwards to · Transport carries requests to the Apps Script relay
- GAS relay → Worker exit: relays · Apps Script forwards authenticated requests to the Worker
- Worker exit → Site: fetches · Worker performs the outbound request to the target site
- Worker exit → Upstream forwarder: optional egress · Worker can send traffic to a stable upstream forwarder
- Upstream forwarder → Site: exits to · Stable VPS-controlled exit reaches the target site
- Startup → Python app: launches · Shell/batch startup scripts start the local Python runtime
- Compose → Upstream forwarder: deploys · Container orchestration for the optional forwarder stack
- Compose → Worker exit: deploys · Containerized deployment artifacts for relay components