32 lines
1012 B
HTML
Executable File
32 lines
1012 B
HTML
Executable File
<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>
|