This commit is contained in:
Lizandro Guarnizo
2025-04-18 07:38:32 -05:00
parent 462eb0d42c
commit 79d6cca94d
23 changed files with 821 additions and 73 deletions
+31
View File
@@ -0,0 +1,31 @@
<div>
<h2>Consola SSH en Vivo</h2>
<pre id="terminal"></pre>
<input type="text" id="command" placeholder="Escribe un comando">
<button onclick="sendCommand()">Enviar</button>
<script>
let id = "{{.id}}"; // Reemplaza con el ID real
const socket = new WebSocket("ws://localhost:8084/app/ws/ssh/" + id);
const terminal = document.getElementById("terminal");
socket.onopen = () => {
terminal.textContent = "Conexión SSH establecida...\n";
};
socket.onmessage = (event) => {
terminal.textContent += event.data;
terminal.scrollTop = terminal.scrollHeight;
};
socket.onerror = (error) => {
console.error("Error en WebSocket:", error);
};
function sendCommand() {
const command = document.getElementById("command").value + "\n";
socket.send(command);
document.getElementById("command").value = "";
}
</script>
</div>