more stuff

This commit is contained in:
2026-08-21 08:45:36 +02:00
parent 5e506c9921
commit ad728ba96c
12 changed files with 1148 additions and 64 deletions

View File

@ -37,6 +37,14 @@
return decodeURIComponent(escape(atob(b64)));
}
// Troubleshooting: der Server liefert bei einem Fehlschlag entweder eine
// {"type":"error",...}-Nachricht ODER (wenn die Sitzung nie so weit kam,
// dass eine Nachricht gesendet werden konnte -- z.B. fehlende
// Berechtigung) eine WebSocket-Close-Reason (siehe
// app/ssh_proxy/terminal_ws.py::_reject). Beides wird angezeigt statt
// eines generischen "Verbindung beendet" ohne jeden Grund.
let lastErrorMessage = null;
const proto = window.location.protocol === "https:" ? "wss:" : "ws:";
const ws = new WebSocket(`${proto}//${window.location.host}/ws/ssh/${hostId}`);
@ -44,15 +52,35 @@
statusEl.textContent = "Verbunden";
sendResize();
});
ws.addEventListener("close", () => { statusEl.textContent = "Verbindung beendet"; });
ws.addEventListener("error", () => { statusEl.textContent = "Verbindungsfehler"; });
ws.addEventListener("close", (ev) => {
let text;
if (lastErrorMessage) {
text = "Verbindung beendet: " + lastErrorMessage;
} else if (ev.reason) {
text = `Verbindung beendet (Code ${ev.code}): ${ev.reason}`;
} else if (ev.code && ev.code !== 1000) {
text = `Verbindung beendet (Code ${ev.code})`;
} else {
text = "Verbindung beendet";
}
statusEl.textContent = text;
statusEl.classList.add("error");
console.error("SSH-Sitzung beendet:", { code: ev.code, reason: ev.reason, lastErrorMessage });
});
ws.addEventListener("error", (ev) => {
statusEl.textContent = "Verbindungsfehler (WebSocket) -- Details siehe Browser-Konsole";
statusEl.classList.add("error");
console.error("SSH-WebSocket-Fehler:", ev);
});
ws.addEventListener("message", (ev) => {
const msg = JSON.parse(ev.data);
if (msg.type === "output") {
term.write(b64decode(msg.data));
} else if (msg.type === "error") {
lastErrorMessage = msg.message;
statusEl.textContent = "Fehler: " + msg.message;
statusEl.classList.add("error");
}
});