Skip to content

Commit 33bba7a

Browse files
committed
v0.2.1: fix PRI/HTTP2-preface leak + shrink SNI-rewrite list
Two bug fixes surfaced in user testing: 1. Invalid HTTP methods forwarded to Apps Script - Browser/xray sent HTTP/2 PRI preface through our MITM despite ALPN being set to http/1.1 only (some clients ignore ALPN). - Our parser accepted 'PRI' as a method and forwarded to Apps Script, which rejected it: 'Exception: parameter provided with invalid value: method'. - Fix: validate method against the standard list (GET/POST/PUT/DELETE/ HEAD/OPTIONS/PATCH/TRACE/CONNECT) at parse time. Non-matching requests close the connection cleanly instead of forwarding garbage. 2. YouTube video playback broken by over-broad SNI-rewrite list - Previous list included googlevideo.com, ytimg.com, doubleclick.net, etc. -- but these are served from SEPARATE CDN pools, NOT from Google's 216.239.38.120 frontend. Rewriting sent traffic to the wrong backend, which Google dropped. - Shrunk to a conservative list that's actually served from the main Google frontend: youtube.com, youtu.be, youtube-nocookie.com, fonts.googleapis.com. Everything else falls through to MITM+relay (slower but actually works). - YouTube video chunks now route through Apps Script which is slow and quota-limited. This is a known limitation inherent to the approach; same issue exists in the original Python version.
1 parent ea5c6ca commit 33bba7a

3 files changed

Lines changed: 28 additions & 14 deletions

File tree

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.0"
3+
version = "0.2.1"
44
edition = "2021"
55
description = "Rust port of MasterHttpRelayVPN -- DPI bypass via Google Apps Script relay with domain fronting"
66
license = "MIT"

src/proxy_server.rs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,16 @@ use crate::config::Config;
1414
use crate::domain_fronter::DomainFronter;
1515
use crate::mitm::MitmCertManager;
1616

17+
// Domains that are served from Google's core frontend IP pool and therefore
18+
// respond correctly when we connect to `google_ip` with SNI=`front_domain`
19+
// and Host=<the real domain>. Kept conservative: anything on a separate CDN
20+
// (googlevideo, ytimg, doubleclick, etc.) is DROPPED because routing to the
21+
// wrong backend breaks rather than helps. Those fall through to the normal
22+
// MITM+relay path, where they'll work (slower) through Apps Script.
1723
const SNI_REWRITE_SUFFIXES: &[&str] = &[
1824
"youtube.com",
1925
"youtu.be",
2026
"youtube-nocookie.com",
21-
"youtubeeducation.com",
22-
"googlevideo.com",
23-
"ytimg.com",
24-
"ggpht.com",
25-
"gvt1.com",
26-
"gvt2.com",
27-
"doubleclick.net",
28-
"googlesyndication.com",
29-
"googleadservices.com",
30-
"google-analytics.com",
31-
"googletagmanager.com",
32-
"googletagservices.com",
3327
"fonts.googleapis.com",
3428
];
3529

@@ -229,6 +223,11 @@ fn parse_request_head(head: &[u8]) -> Option<(String, String, String, Vec<(Strin
229223
let method = parts.next()?.to_string();
230224
let target = parts.next()?.to_string();
231225
let version = parts.next().unwrap_or("HTTP/1.1").to_string();
226+
227+
if !is_valid_http_method(&method) {
228+
return None;
229+
}
230+
232231
let mut headers = Vec::new();
233232
for l in lines {
234233
if l.is_empty() {
@@ -241,6 +240,21 @@ fn parse_request_head(head: &[u8]) -> Option<(String, String, String, Vec<(Strin
241240
Some((method, target, version, headers))
242241
}
243242

243+
fn is_valid_http_method(m: &str) -> bool {
244+
matches!(
245+
m,
246+
"GET"
247+
| "POST"
248+
| "PUT"
249+
| "DELETE"
250+
| "HEAD"
251+
| "OPTIONS"
252+
| "PATCH"
253+
| "TRACE"
254+
| "CONNECT"
255+
)
256+
}
257+
244258
// ---------- CONNECT handling ----------
245259

246260
async fn do_connect(

0 commit comments

Comments
 (0)