Skip to content

Commit f5397be

Browse files
committed
v0.3.0: SOCKS5 listener + smart TLS/HTTP/plain-TCP dispatch
Ports the SOCKS5 + fallback-chain design from @masterking32's MasterHTTP-WithSOCKS branch so xray / Telegram / app-level TCP clients work through this proxy. Changes: - New SOCKS5 listener on listen_port+1 (configurable via socks5_port) - RFC 1928 CONNECT handshake (v5, no-auth, ATYP IPv4/domain/IPv6) - Shared smart dispatch with the HTTP-CONNECT path - Unified dispatch_tunnel() used by both CONNECT entry points: 1. If host matches SNI-rewrite suffix or hosts override: go direct to google_ip via the MITM+TLS tunnel (fast path for google.com, youtube, etc.) 2. Peek the first byte (300ms timeout for server-first protocols): - 0x16: TLS client hello -> MITM + relay via Apps Script (scheme=https) - HTTP method signature: HTTP relay via Apps Script (scheme=http) - Anything else or timeout: plain TCP passthrough to the target - handle_mitm_request() now takes a scheme arg (http/https) so the same code path handles both MITM'd HTTPS and port-80 plain HTTP - New plain_tcp_passthrough helper: bidirectional TCP bridge used as the final fallback (covers MTProto / raw TCP / server-first protos) Config: - Added optional socks5_port field; defaults to listen_port+1 README: - Added browser vs xray/Telegram instructions under 'Step 6' Live-tested: HTTP proxy, HTTP proxy -> HTTPS, SOCKS5 -> HTTP, SOCKS5 -> HTTPS, Google search via SNI-tunnel (now returns full JS page) all pass.
1 parent 343def4 commit f5397be

8 files changed

Lines changed: 309 additions & 61 deletions

File tree

.DS_Store

10 KB
Binary file not shown.

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mhrv-rs"
3-
version = "0.2.2"
3+
version = "0.3.0"
44
edition = "2021"
55
description = "Rust port of MasterHttpRelayVPN -- DPI bypass via Google Apps Script relay with domain fronting"
66
license = "MIT"

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,21 @@ mhrv-rs.exe --config config.json # Windows
9898
- **`mhrv-rs test`** — send one request through the relay and report success/timing. Useful when setting up or debugging. Does not need the proxy to be running.
9999
- **`mhrv-rs scan-ips`** — parallel TLS probe of known Google frontend IPs, sorted by latency. Swap the winning IP into your `google_ip` config field for best performance.
100100

101-
### Step 6: Point your browser at the proxy
101+
### Step 6: Point your client at the proxy
102102

103-
Configure your browser to use HTTP proxy `127.0.0.1:8085`.
103+
The tool listens on **two** ports:
104+
- **HTTP proxy** on `listen_port` (default `8085`) — for browsers / any HTTP-aware client
105+
- **SOCKS5 proxy** on `socks5_port` (default `listen_port + 1`, i.e. `8086`) — for xray / Telegram / app-level clients
104106

105-
- **Firefox**: Settings → Network Settings → Manual proxy → enter for HTTP, check "Also use this proxy for HTTPS"
106-
- **Chrome/Edge**: System proxy settings, or use SwitchyOmega extension
107+
**Browser (HTTP proxy):**
108+
- **Firefox**: Settings → Network Settings → Manual proxy → HTTP `127.0.0.1:8085`, check "Also use this proxy for HTTPS"
109+
- **Chrome/Edge**: System proxy settings, or SwitchyOmega
107110
- **macOS system-wide**: System Settings → Network → Wi-Fi → Details → Proxies → Web + Secure Web Proxy
108111

112+
**xray / Telegram (SOCKS5):**
113+
- Point the SOCKS5 setting at `127.0.0.1:8086`, no auth.
114+
- Non-HTTP protocols (MTProto, raw TCP) fall back to plain-TCP passthrough automatically.
115+
109116
## What's implemented vs not
110117

111118
This port focuses on the **`apps_script` mode** which is the only one that reliably works in 2026. Implemented:

config.example.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"auth_key": "CHANGE_ME_TO_A_STRONG_SECRET",
77
"listen_host": "127.0.0.1",
88
"listen_port": 8085,
9+
"socks5_port": 8086,
910
"log_level": "info",
1011
"verify_ssl": true,
1112
"hosts": {}

src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ pub struct Config {
4444
pub listen_host: String,
4545
#[serde(default = "default_listen_port")]
4646
pub listen_port: u16,
47+
#[serde(default)]
48+
pub socks5_port: Option<u16>,
4749
#[serde(default = "default_log_level")]
4850
pub log_level: String,
4951
#[serde(default = "default_verify_ssl")]

src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ async fn main() -> ExitCode {
176176
Command::Serve => {}
177177
}
178178

179+
let socks5_port = config.socks5_port.unwrap_or(config.listen_port + 1);
179180
tracing::warn!("mhrv-rs {} starting (mode: apps_script)", VERSION);
181+
tracing::info!("HTTP proxy : {}:{}", config.listen_host, config.listen_port);
182+
tracing::info!("SOCKS5 proxy : {}:{}", config.listen_host, socks5_port);
180183
tracing::info!(
181184
"Apps Script relay: SNI={} -> script.google.com (via {})",
182185
config.front_domain,

0 commit comments

Comments
 (0)