refactor: remove unneccessary variable assignment
This commit is contained in:
parent
50cfcb9778
commit
57af568586
1 changed files with 8 additions and 15 deletions
|
@ -22,25 +22,20 @@ let termRows;
|
||||||
* @param {object} err Error object
|
* @param {object} err Error object
|
||||||
*/
|
*/
|
||||||
function connError(socket, err) {
|
function connError(socket, err) {
|
||||||
|
let msg = util.inspect(err);
|
||||||
|
const { session } = socket.request.session;
|
||||||
if (err?.level === 'client-authentication') {
|
if (err?.level === 'client-authentication') {
|
||||||
logError(
|
msg = `Authentication failure user=${session.username} from=${socket.handshake.address}`;
|
||||||
socket,
|
socket.emit('allowreauth', session.ssh.allowreauth);
|
||||||
'CONN ERROR',
|
|
||||||
`Authentication failure user=${socket.request.session.username} from=${socket.handshake.address}`
|
|
||||||
);
|
|
||||||
socket.emit('allowreauth', socket.request.session.ssh.allowreauth);
|
|
||||||
socket.emit('reauth');
|
socket.emit('reauth');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (err?.code === 'ENOTFOUND') {
|
if (err?.code === 'ENOTFOUND') {
|
||||||
logError(socket, 'CONN ERROR', `Host not found: ${err.hostname}`);
|
msg = `Host not found: ${err.hostname}`;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (err?.level === 'client-timeout') {
|
if (err?.level === 'client-timeout') {
|
||||||
logError(socket, 'CONN ERROR', `Connection Timeout: ${socket.request.session.ssh.host}`);
|
msg = `Connection Timeout: ${session.ssh.host}`;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
logError(socket, 'CONN ERROR', util.inspect(err));
|
logError(socket, 'CONN ERROR', msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,9 +152,7 @@ module.exports = function appSocket(socket) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
socket.once('disconnect', (reason) => {
|
socket.once('disconnect', (reason) => {
|
||||||
webssh2debug(socket, `SOCKET DISCONNECT: ${reason}`);
|
webssh2debug(socket, `CLIENT SOCKET DISCONNECT: ${util.inspect(reason)}`);
|
||||||
const errMsg = { message: reason };
|
|
||||||
// logError(socket, 'CLIENT SOCKET DISCONNECT', util.inspect(errMsg));
|
|
||||||
conn.end();
|
conn.end();
|
||||||
socket.request.session.destroy();
|
socket.request.session.destroy();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue