vivekchakraverty commited on
Commit
2c99193
Β·
verified Β·
1 Parent(s): 38755c0

Add discriminating reachability probe battery (MTU vs hostname-filter vs reset)

Browse files
Files changed (1) hide show
  1. app.py +43 -32
app.py CHANGED
@@ -105,38 +105,49 @@ def check_access():
105
  lines.append(f"- **Egress IP** {'(via proxy)' if proxy else '(Space direct)'}: `{ip}`")
106
  except Exception as exc:
107
  lines.append(f"- **Egress IP**: ❌ {type(exc).__name__}")
108
- yt = "https://www.youtube.com/robots.txt"
109
- last = None
110
- for attempt in range(3): # tolerate a transient TLS reset from the exit IP
111
- try:
112
- r = requests.get(yt, proxies=proxies, timeout=20)
113
- lines.append(f"- **YouTube reachable**: βœ… HTTP {r.status_code}"
114
- + (f" (after {attempt + 1} tries)" if attempt else ""))
115
- verdict = "### 🟒 YouTube is reachable β€” transcript + screenshots should work."
116
- return verdict + "\n\n" + "\n".join(lines)
117
- except Exception as exc:
118
- last = exc
119
- time.sleep(1.5)
120
- # All retries failed β€” classify: CA-trust failure vs connection/handshake reset.
121
- detail = f"`{type(last).__name__}: {str(last)[:160]}`"
122
- if isinstance(last, requests.exceptions.SSLError):
123
- try:
124
- import urllib3
125
- urllib3.disable_warnings()
126
- r = requests.get(yt, proxies=proxies, timeout=20, verify=False)
127
- lines.append(f"- **YouTube reachable**: ⚠️ only with TLS verify OFF (HTTP "
128
- f"{r.status_code}) β†’ stale CA bundle. {detail}")
129
- verdict = ("### 🟠 YouTube reachable, but the Space can't verify its certificate.\n"
130
- "Bump **`certifi`** in requirements.txt and rebuild the Space.")
131
- return verdict + "\n\n" + "\n".join(lines)
132
- except Exception as exc2:
133
- detail = (f"verify-on: `{type(last).__name__}: {str(last)[:110]}` Β· "
134
- f"verify-off: `{type(exc2).__name__}: {str(exc2)[:110]}`")
135
- lines.append(f"- **YouTube reachable**: ❌ {detail}")
136
- verdict = ("### πŸ”΄ YouTube is NOT reachable from the Space.\n"
137
- "The proxy connects but YouTube's TLS is failing/reset (often the exit IP being "
138
- "rate-limited β€” try again in a minute). If it persists, set/refresh a residential "
139
- "**`YT_PROXY`** via the home-tunnel panel in [`tools/`](tools/README.md).")
 
 
 
 
 
 
 
 
 
 
 
140
  return verdict + "\n\n" + "\n".join(lines)
141
 
142
 
 
105
  lines.append(f"- **Egress IP** {'(via proxy)' if proxy else '(Space direct)'}: `{ip}`")
106
  except Exception as exc:
107
  lines.append(f"- **Egress IP**: ❌ {type(exc).__name__}")
108
+ def probe(url):
109
+ last = None
110
+ for _ in range(2): # tolerate a single transient reset
111
+ try:
112
+ r = requests.get(url, proxies=proxies, timeout=20)
113
+ return True, f"HTTP {r.status_code}"
114
+ except Exception as exc:
115
+ last = exc
116
+ time.sleep(1.0)
117
+ return False, f"{type(last).__name__}: {str(last)[:90]}"
118
+
119
+ # Discriminating battery: neutral-small vs Google-family (same big cert as
120
+ # YouTube, different hostname) vs YouTube itself. The pass/fail pattern says
121
+ # whether it's a size/MTU blackhole, hostname-based egress filtering, or reset.
122
+ probes = [
123
+ ("example.com (neutral)", "https://example.com"),
124
+ ("google.com/204 (Google cert, non-YT name)", "https://www.google.com/generate_204"),
125
+ ("youtube.com/robots.txt", "https://www.youtube.com/robots.txt"),
126
+ ("youtube.com/ (large body)", "https://www.youtube.com/"),
127
+ ]
128
+ results = {}
129
+ for label, url in probes:
130
+ ok, msg = probe(url)
131
+ results[label] = ok
132
+ lines.append(f"- {'βœ…' if ok else '❌'} {label}: {msg}")
133
+
134
+ yt_ok = results.get("youtube.com/robots.txt")
135
+ if yt_ok:
136
+ verdict = "### 🟒 YouTube is reachable β€” transcript + screenshots should work."
137
+ elif results.get("google.com/204 (Google cert, non-YT name)"):
138
+ verdict = ("### πŸ”΄ YouTube is filtered by hostname.\n"
139
+ "Google works but YouTube is reset β†’ the network between the Space and the "
140
+ "tunnel is dropping the plaintext `CONNECT www.youtube.com`. Fix: run the "
141
+ "home proxy as an **HTTPS proxy** (TLS-wrapped) so the target host is hidden.")
142
+ elif results.get("example.com (neutral)") and not results.get("google.com/204 (Google cert, non-YT name)"):
143
+ verdict = ("### πŸ”΄ Large TLS handshakes are being dropped (MTU blackhole).\n"
144
+ "Small sites work; Google/YouTube (large cert chains) reset. Fix: clamp MSS on "
145
+ "the tunnel path or switch tunnel provider (e.g. ngrok).")
146
+ else:
147
+ verdict = ("### πŸ”΄ YouTube is NOT reachable from the Space.\n"
148
+ "The proxy connects (egress IP works) but TLS to YouTube is failing. "
149
+ "Try again in a minute or refresh **`YT_PROXY`** via the panel in "
150
+ "[`tools/`](tools/README.md).")
151
  return verdict + "\n\n" + "\n".join(lines)
152
 
153