Commit 675df299 authored by nextime's avatar nextime

Simplify terminal echo: let SSH server control echo behavior

- Remove JavaScript-based echo handling and password mode detection
- Send all keystrokes directly to server without local echo manipulation
- Let SSH server handle echo control through terminal protocol
- Proper terminal behavior where server controls what gets displayed
- No more manual echo logic, respects SSH server's echo settings
parent c0b3a4bd
...@@ -34,7 +34,6 @@ let term = null; ...@@ -34,7 +34,6 @@ let term = null;
let connected = false; let connected = false;
let requestId = null; let requestId = null;
let pollInterval = null; let pollInterval = null;
let passwordMode = false;
document.getElementById('connectBtn').addEventListener('click', connect); document.getElementById('connectBtn').addEventListener('click', connect);
document.getElementById('disconnectBtn').addEventListener('click', disconnect); document.getElementById('disconnectBtn').addEventListener('click', disconnect);
...@@ -130,30 +129,11 @@ function connect() { ...@@ -130,30 +129,11 @@ function connect() {
disconnect(); disconnect();
}); });
// Handle input - send to server and handle local echo // Handle input - send all keystrokes to server, let SSH handle echo
term.onData(data => { term.onData(data => {
if (!connected || !requestId) return; if (!connected || !requestId) return;
// Handle special characters for local echo // Send all input to server, let SSH handle echo and display
if (data === '\r' || data === '\n') {
// Enter key - let server handle the command execution
term.write('\r\n');
// Exit password mode after enter
passwordMode = false;
} else if (data === '\x7f' || data === '\b') {
// Backspace - handle locally only if not in password mode
if (!passwordMode) {
term.write('\b \b');
}
} else if (data >= ' ' && data <= '~') {
// Printable characters - echo locally only if not in password mode
if (!passwordMode) {
term.write(data);
}
// Stay in password mode for printable characters
}
// Send data to server
fetch('/terminal/{{ client_id }}/data', { fetch('/terminal/{{ client_id }}/data', {
method: 'POST', method: 'POST',
headers: { headers: {
...@@ -166,7 +146,6 @@ function connect() { ...@@ -166,7 +146,6 @@ function connect() {
function disconnect() { function disconnect() {
connected = false; connected = false;
passwordMode = false; // Reset password mode
document.getElementById('connectBtn').disabled = false; document.getElementById('connectBtn').disabled = false;
document.getElementById('disconnectBtn').disabled = true; document.getElementById('disconnectBtn').disabled = true;
document.getElementById('sshUsername').disabled = false; document.getElementById('sshUsername').disabled = false;
...@@ -198,20 +177,7 @@ function pollData() { ...@@ -198,20 +177,7 @@ function pollData() {
.then(response => response.text()) .then(response => response.text())
.then(data => { .then(data => {
if (data) { if (data) {
// Check for password prompts // Let the server handle all echo and display logic
if (data.toLowerCase().includes('password:') ||
data.toLowerCase().includes('password for') ||
data.toLowerCase().includes('enter passphrase')) {
passwordMode = true;
}
// Check for end of password prompt (new prompt or command output)
if (passwordMode && (data.includes('$ ') || data.includes('# ') ||
data.includes('> ') || data.includes('\n$') || data.includes('\n#'))) {
passwordMode = false;
}
// Ensure proper line ending handling
term.write(data.replace(/\n/g, '\r\n')); term.write(data.replace(/\n/g, '\r\n'));
} }
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment