Commit 8afc4e5
committed
bugfix(web): Do not open the LAN relay socket from an https page
emscripten_websocket_new passes its URL straight to the WebSocket constructor, and
a browser does not merely refuse a ws:// socket opened from an https:// page - it
throws a SecurityError out of the constructor. That unwound through main() and
killed the engine before it drew a frame, so the hosted page stopped working
altogether the moment the relay was connected at startup. The same throw was
waiting in UDP::Bind for anyone opening the LAN screen there.
Decide the URL in JS and let it answer "no relay": plain ws:// only for a page that
is not https, ?relay=<url> to name a reachable (wss://) one, and an empty answer
means skip the socket entirely. relay.py speaks plain ws and is a local dev tool,
so a hosted page has nothing to reach by default - LAN is unavailable there, which
is not fatal, unlike the crash.
Verified the three cases (http, https, https with ?relay=) against the extracted
EM_ASM body.1 parent 1860f61 commit 8afc4e5
1 file changed
Lines changed: 19 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
89 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
90 | 107 | | |
91 | 108 | | |
92 | 109 | | |
| |||
0 commit comments