Spaces:
Sleeping
Sleeping
Add discriminating reachability probe battery (MTU vs hostname-filter vs reset)
Browse files
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 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
#
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|