Improved SSH error messages.
This commit is contained in:
parent
5bb6045a8b
commit
5757811b9c
19
apprelays.js
19
apprelays.js
|
@ -455,6 +455,8 @@ module.exports.CreateSshTerminalRelay = function (parent, db, ws, req, domain, u
|
|||
obj.sshShell.on('close', function () { obj.close(); });
|
||||
obj.sshShell.on('data', function (data) { obj.ws.send('~' + data.toString()); });
|
||||
});
|
||||
|
||||
obj.connected = true;
|
||||
obj.ws.send('c');
|
||||
});
|
||||
obj.sshClient.on('error', function (err) {
|
||||
|
@ -479,7 +481,10 @@ module.exports.CreateSshTerminalRelay = function (parent, db, ws, req, domain, u
|
|||
if ((data.length > 0) && (obj.ser != null)) { try { obj.ser.updateBuffer(data); } catch (ex) { console.log(ex); } }
|
||||
}
|
||||
});
|
||||
obj.wsClient.on('close', function () { parent.parent.debug('relay', 'SSH: Relay websocket closed'); obj.close(); });
|
||||
obj.wsClient.on('close', function () {
|
||||
if (obj.connected !== true) { try { obj.ws.send(JSON.stringify({ action: 'connectionerror' })); } catch (ex) { } }
|
||||
parent.parent.debug('relay', 'SSH: Relay websocket closed'); obj.close();
|
||||
});
|
||||
obj.wsClient.on('error', function (err) { parent.parent.debug('relay', 'SSH: Relay websocket error: ' + err); obj.close(); });
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
|
@ -700,11 +705,13 @@ module.exports.CreateSshFilesRelay = function (parent, db, ws, req, domain, user
|
|||
if (obj.keep === true) saveSshCredentials();
|
||||
obj.sshClient.sftp(function(err, sftp) {
|
||||
if (err) { obj.close(); return; }
|
||||
obj.connected = true;
|
||||
obj.sftp = sftp;
|
||||
obj.ws.send('c');
|
||||
});
|
||||
});
|
||||
obj.sshClient.on('error', function (err) {
|
||||
console.log('error', err);
|
||||
if (err.level == 'client-authentication') { try { obj.ws.send(JSON.stringify({ action: 'autherror' })); } catch (ex) { } }
|
||||
if (err.level == 'client-timeout') { try { obj.ws.send(JSON.stringify({ action: 'sessiontimeout' })); } catch (ex) { } }
|
||||
obj.close();
|
||||
|
@ -726,7 +733,10 @@ module.exports.CreateSshFilesRelay = function (parent, db, ws, req, domain, user
|
|||
if ((data.length > 0) && (obj.ser != null)) { try { obj.ser.updateBuffer(data); } catch (ex) { console.log(ex); } }
|
||||
}
|
||||
});
|
||||
obj.wsClient.on('close', function () { parent.parent.debug('relay', 'SSH: Files relay websocket closed'); obj.close(); });
|
||||
obj.wsClient.on('close', function () {
|
||||
if (obj.connected !== true) { try { obj.ws.send(JSON.stringify({ action: 'connectionerror' })); } catch (ex) { } }
|
||||
parent.parent.debug('relay', 'SSH: Files relay websocket closed'); obj.close();
|
||||
});
|
||||
obj.wsClient.on('error', function (err) { parent.parent.debug('relay', 'SSH: Files relay websocket error: ' + err); obj.close(); });
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
|
@ -736,7 +746,7 @@ module.exports.CreateSshFilesRelay = function (parent, db, ws, req, domain, user
|
|||
// When data is received from the web socket
|
||||
// SSH default port is 22
|
||||
ws.on('message', function (msg) {
|
||||
if ((obj.firstMessage === true) && (msg != 5)) { obj.close(); return; } else { delete obj.firstMessage; }
|
||||
//if ((obj.firstMessage === true) && (msg != 5)) { obj.close(); return; } else { delete obj.firstMessage; }
|
||||
try {
|
||||
if (typeof msg != 'string') {
|
||||
if (msg[0] == 123) {
|
||||
|
@ -904,9 +914,8 @@ module.exports.CreateSshFilesRelay = function (parent, db, ws, req, domain, user
|
|||
|
||||
// Verify inputs
|
||||
if ((typeof msg.username != 'string') || (typeof msg.password != 'string')) break;
|
||||
if ((typeof msg.rows != 'number') || (typeof msg.cols != 'number') || (typeof msg.height != 'number') || (typeof msg.width != 'number')) break;
|
||||
|
||||
obj.keep = msg.keep; // If true, keep store credentials on the server if the SSH tunnel connected succesfully.
|
||||
obj.keep = (msg.keep === true); // If true, keep store credentials on the server if the SSH tunnel connected succesfully.
|
||||
obj.username = msg.username;
|
||||
obj.password = msg.password;
|
||||
|
||||
|
|
|
@ -699,8 +699,8 @@
|
|||
<div id="idx_termFullBtn2" onclick=deskToggleFull(event)> ✖</div>
|
||||
<input type="button" id="autoconnectbutton2" value="AutoConnect" onclick=autoConnectTerminal(event) onkeypress="return false" onkeydown="return false" style="display:none" />
|
||||
<span id="connectbutton2span"><input type="button" id="connectbutton2" cmenu="termConnectButton" value="Connect" onclick=connectTerminal(event,1) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
|
||||
<span id="connectbutton2hspan"> <input type="button" id="connectbutton2h" value="HW Connect" title="Connect using Intel® AMT hardware KVM" onclick=connectTerminal(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
|
||||
<span id="disconnectbutton2span"> <input type="button" id="disconnectbutton2" value="Disconnect" onclick=connectTerminal(event,0) onkeypress="return false" onkeydown="return false" /></span>
|
||||
<span id="connectbutton2hspan"><input type="button" id="connectbutton2h" value="HW Connect" title="Connect using Intel® AMT hardware KVM" onclick=connectTerminal(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
|
||||
<span id="disconnectbutton2span"><input type="button" id="disconnectbutton2" value="Disconnect" onclick=connectTerminal(event,0) onkeypress="return false" onkeydown="return false" /></span>
|
||||
<span id="termstatus" style="line-height:22px">Disconnected</span><span id="termtitle"></span>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -7830,6 +7830,17 @@
|
|||
}
|
||||
}
|
||||
|
||||
function p13setConsoleMsg(msg, timeout) {
|
||||
if (msg) {
|
||||
Q('p13FilesConsoleMsg').innerHTML += msg;
|
||||
QV('p13FilesConsoleMsg', true);
|
||||
if (p13FilesConsoleMsgTimer != null) { clearTimeout(p13FilesConsoleMsgTimer); }
|
||||
if (timeout) { p13FilesConsoleMsgTimer = setTimeout(p13clearConsoleMsg, timeout); }
|
||||
} else {
|
||||
p13clearConsoleMsg();
|
||||
}
|
||||
}
|
||||
|
||||
var webRtcDesktop = null;
|
||||
function webRtcDesktopReset() {
|
||||
if (webRtcDesktop == null) return;
|
||||
|
@ -8715,6 +8726,7 @@
|
|||
terminal.socket.send(JSON.stringify({ action: 'sshautoauth', cols: xterm.cols, rows: xterm.rows, width: Q('termarea3xdiv').offsetWidth, height: Q('termarea3xdiv').offsetHeight }));
|
||||
break;
|
||||
}
|
||||
case 'connectionerror': { p12setConsoleMsg("Connection Error", 5000); break; }
|
||||
case 'autherror': { p12setConsoleMsg("Authentication Error", 5000); break; }
|
||||
case 'sessionerror': { p12setConsoleMsg("Session expired", 5000); break; }
|
||||
case 'sessiontimeout': { p12setConsoleMsg("Session timeout", 5000); break; }
|
||||
|
@ -9053,6 +9065,23 @@
|
|||
// Process file upload commands
|
||||
if ((data.action != null) && (data.action.startsWith('upload'))) { p13gotUploadData(data); return; }
|
||||
|
||||
// Process any SSH actions
|
||||
switch (data.action) {
|
||||
case 'sshauth': {
|
||||
var x = '';
|
||||
x += addHtmlValue("Username", '<input id=dp2user style=width:230px maxlength=64 autocomplete=off onkeyup=sshAuthKeyUp(event) />');
|
||||
x += addHtmlValue("Password", '<input type=password id=dp2pass style=width:230px maxlength=64 autocomplete=off onkeyup=sshAuthKeyUp(event) />');
|
||||
x += addHtmlValue('', '<label><input id=dp2keep type=checkbox>' + "Remember credentials" + '</label>');
|
||||
setDialogMode(2, "Authentication", 11, p13sshConnectEx, x, 'ssh');
|
||||
setTimeout(sshAuthKeyUp, 50);
|
||||
return;
|
||||
}
|
||||
case 'autherror': { p13setConsoleMsg("Authentication Error", 5000); return; }
|
||||
case 'connectionerror': { p13setConsoleMsg("Connection Error", 5000); return; }
|
||||
case 'sessionerror': { p13setConsoleMsg("Session expired", 5000); return; }
|
||||
case 'sessiontimeout': { p13setConsoleMsg("Session timeout", 5000); return; }
|
||||
}
|
||||
|
||||
// Display a dialog message
|
||||
if (data.action == 'dialogmessage') {
|
||||
if ((data.msg == null) && (xxdialogTag == 'fileMsgDialog')) {
|
||||
|
@ -9091,6 +9120,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
function p13sshConnectEx(b) {
|
||||
if (b == 0) {
|
||||
if (files != null) { connectFiles(); } // Disconnect
|
||||
} else {
|
||||
files.socket.send(JSON.stringify({ action: 'sshauth', username: Q('dp2user').value, password: Q('dp2pass').value, keep: Q('dp2keep').checked }));
|
||||
}
|
||||
}
|
||||
|
||||
function p13getCheckedNames() {
|
||||
// Save all existing checked boxes
|
||||
var checkedNames = [], checkboxes = document.getElementsByName('fd');
|
||||
|
|
Loading…
Reference in New Issue