Skip to content

ThisIsDara/mhr-cfw-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MHR-CFW Rewritten in Go with YouTube Support Fix and Speed Improvements

GitHub

فارسی

image

πŸš€ Improvements Over Python Version

βœ… 1. YouTube Support Fixed

  • Proper CORS handling β€” Added preflight OPTIONS handling and CORS header injection for cross-origin requests
  • Content-Encoding fix β€” Better decoding for brotli/gzip responses
  • Range request support β€” Video streaming needs proper Range header handling

βœ… 2. Speed Improvements

  • HTTP/2 transport β€” Uses HTTP/2 instead of HTTP/1.1 (faster multiplexing)
  • Connection pooling β€” Reuses TLS connections instead of creating new ones
  • Request coalescing β€” Multiple GET requests for same URL share one relay call
  • Response caching β€” LRU cache with proper TTL for static assets

βœ… 3. Security

  • RSA 4096-bit keys β€” Upgraded from 2048-bit for MITM certificates

βœ… 4. Reliability

  • Proper signal handling β€” Clean shutdown on Ctrl+C
  • Graceful error handling β€” Better error responses

βœ… 5. Code Quality

  • Go rewrite β€” Static typing, better memory management
  • No external dependencies β€” Uses standard library where possible

How It Works

The program runs on your PC and sends your requests through Google's infrastructure. Network filters see ordinary Google traffic and allow it through. Meanwhile, Google's free Apps Script fetches the actual website you wanted.


Quick Start

πŸ“¦ Requirements:

πŸ’‘ Tip: If you have trouble downloading Go dependencies, use the Runflare Iranian mirror:

GOPROXY=https://mirror-go.runflare.com go mod download

1 - Clone and Build

git clone https://github.com/ThisIsDara/mhr-cfw-go.git
cd mhr-cfw-go

Or download the latest release from πŸ“₯ GitHub Releases

2 - Build

Windows: Double-click build.bat or run:

.\build.bat

Linux/Mac: Make the script executable and run:

chmod +x build.sh
./build.sh

This will build the executable (mhr-cfw-go.exe on Windows, mhr-cfw-go on Linux/Mac).

3 - Configure

Edit config.json with your settings or ideally run Setup Wizard in the TUI:

{
  "auth_key": "your-secret-password-here",
  "script_id": "YOUR_DEPLOYMENT_ID"
}

4 - Run

Windows: Double-click mhr-cfw-go.exe or run:

.\mhr-cfw-go.exe

Linux/Mac: Run:

./mhr-cfw-go

The app opens an interactive menu. Select 1) Start proxy to begin.


5 - Install CA Certificate (for HTTPS interception)

Run the app, then select 3) Install CA certificate from the menu.

This installs the local Certificate Authority so the proxy can intercept HTTPS traffic.


🐧 Linux / 🍎 macOS / πŸ“± Termux Guide

Linux/macOS

# Clone
git clone https://github.com/ThisIsDara/mhr-cfw-go.git
cd mhr-cfw-go

# Build
chmod +x build.sh
./build.sh

# Run
./mhr-cfw-go

Or manually:

GOOS=linux go build -ldflags "-s -w" -o mhr-cfw-go ./cmd/mhr-cfw
./mhr-cfw-go

Termux (Android)

# Install Go and Git
pkg update -y
pkg install -y golang git

# Clone
git clone https://github.com/ThisIsDara/mhr-cfw-go.git
cd mhr-cfw-go

# Build
chmod +x build.sh
./build.sh

# Run
./mhr-cfw-go

Stopping

Press Ctrl+C to stop the proxy.


πŸ› οΈ How to Setup

  1. Open mhr-cfw README File provided by denuitt1 and follow the steps 1 to 3 until you have the Deployment ID

Building from Source

Requirements:

go build -ldflags "-s -w" -o mhr-cfw-go.exe ./cmd/mhr-cfw

WIP...

πŸ“Š Statistics

  • Request counter β€” Total requests served
  • Bandwidth usage β€” Bytes sent/received

πŸ–₯️ Monitoring

  • Connection status

✏️ UX

  • Profile switching β€” Different config profiles
  • Export/Import config β€” Backup settings

Command Line Options

Option Description
--no-menu Run without TUI menu
--port Override proxy port
--host Override listen host
--socks5-port Override SOCKS5 port
--disable-socks5 Disable SOCKS5 proxy
--log-level Set log level (DEBUG, INFO, WARN, ERROR)
--install-cert Install CA certificate
--uninstall-cert Remove CA certificate
--scan Scan Google IPs
--setup Run setup wizard
--version Show version

Disclaimer

  • Google services compliance: If you use Google Apps Script or other Google services with this project, you are responsible for complying with Google's Terms of Service, acceptable use rules, quotas, and platform policies. Misuse may lead to suspension or termination of your Google account or deployments.

Original Projects

Based on mhr-cfw, The Python implementation this project was rewritten from.

License

MIT

About

A local proxy that runs on your machine and forwards traffic through Google.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors