diff --git a/Protest/Front/ssh.js b/Protest/Front/ssh.js index 946f6436..e7f5b808 100644 --- a/Protest/Front/ssh.js +++ b/Protest/Front/ssh.js @@ -69,6 +69,8 @@ class Ssh extends Terminal { } okButton.onclick = ()=> { + this.params.username = usernameInput.value.trim(); + if (rememberPasswordCheckBox.checked) { this.params.password = passwordInput.value; } @@ -95,7 +97,6 @@ class Ssh extends Terminal { hostInput.onkeydown = usernameInput.onkeydown = passwordInput.onkeydown = event=> { if (dialog.okButton.disabled) return; if (event.key === "Enter") { - this.params.username = usernameInput.value.trim(); dialog.okButton.click(); } }; @@ -178,7 +179,11 @@ class Ssh extends Terminal { this.content.focus(); } else if (json.error) { - setTimeout(()=>{ this.ConfirmBox(json.error, true, "mono/error.svg"); }, 200); + setTimeout(()=>{ + this.ConfirmBox(json.error, true, "mono/error.svg").addEventListener("click", ()=> { + setTimeout(()=>this.ConnectDialog(this.params.host, false), 200); + }); + }, 200); } }; } diff --git a/Protest/Front/terminal.js b/Protest/Front/terminal.js index 065d0080..0f1c8b9a 100644 --- a/Protest/Front/terminal.js +++ b/Protest/Front/terminal.js @@ -421,7 +421,7 @@ class Terminal extends Window { this.cursorElement.style.top = Terminal.CURSOR_HEIGHT * this.cursor.y + "px"; if (this.params.autoScroll) { - this.cursorElement.scrollIntoView(); + setTimeout(()=>this.cursorElement.scrollIntoView(), 250); } } @@ -575,8 +575,6 @@ class Terminal extends Window { const sequence = data.slice(index + 2, end); const [command, ...params] = sequence.split(";"); - console.log(command, params); - switch (command) { case "0": case "2": //set title diff --git a/Protest/Protocols/Ssh.cs b/Protest/Protocols/Ssh.cs index 34a3e998..85f50c5e 100644 --- a/Protest/Protocols/Ssh.cs +++ b/Protest/Protocols/Ssh.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Protest.Http; using Renci.SshNet; +using Renci.SshNet.Common; namespace Protest.Protocols; @@ -95,6 +96,11 @@ public static async void WebSocketHandler(HttpListenerContext ctx) { shellStream.Write(Encoding.ASCII.GetString(buff, 0, receiveResult.Count)); } } + catch (SshAuthenticationException) { + await WsWriteText(ws, "{\"error\":\"Invalid username or password\"}"); + await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, String.Empty, CancellationToken.None); + return; + } catch (SocketException ex) { await WsWriteText(ws, $"{{\"error\":\"{ex.Message}\"}}"); await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, String.Empty, CancellationToken.None);