chore: light refactoring
This commit is contained in:
parent
cc8b014af8
commit
266f9876d3
2 changed files with 18 additions and 22 deletions
36
app/app.js
36
app/app.js
|
@ -54,23 +54,12 @@ function createApp() {
|
|||
return { app, sessionMiddleware }
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and configures the HTTP server
|
||||
* @param {express.Application} app - The Express application instance
|
||||
* @returns {http.Server} The HTTP server instance
|
||||
*/
|
||||
function createServer(app) {
|
||||
return http.createServer(app)
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures Socket.IO with the given server
|
||||
* @param {http.Server} server - The HTTP server instance
|
||||
* @param {Function} sessionMiddleware - The session middleware
|
||||
* @returns {import('socket.io').Server} The Socket.IO server instance
|
||||
*/
|
||||
// var io = require('socket.io')(server, { serveClient: false, path: '/ssh/socket.io', origins: config.http.origins })
|
||||
|
||||
function configureSocketIO(server, sessionMiddleware) {
|
||||
const io = socketIo(server, {
|
||||
serveClient: false,
|
||||
|
@ -90,6 +79,15 @@ function configureSocketIO(server, sessionMiddleware) {
|
|||
return io
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and configures the HTTP server
|
||||
* @param {express.Application} app - The Express application instance
|
||||
* @returns {http.Server} The HTTP server instance
|
||||
*/
|
||||
function createServer(app) {
|
||||
return http.createServer(app)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the CORS configuration
|
||||
* @returns {Object} The CORS configuration object
|
||||
|
@ -103,11 +101,11 @@ function getCorsConfig() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets up Socket.IO event listeners
|
||||
* @param {import('socket.io').Server} io - The Socket.IO server instance
|
||||
* Handles server errors
|
||||
* @param {Error} err - The error object
|
||||
*/
|
||||
function setupSocketIOListeners(io) {
|
||||
socketHandler(io, config)
|
||||
function handleServerError(err) {
|
||||
console.error("WebSSH2 server.listen ERROR:", err.code)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,11 +133,11 @@ function startServer() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Handles server errors
|
||||
* @param {Error} err - The error object
|
||||
* Sets up Socket.IO event listeners
|
||||
* @param {import('socket.io').Server} io - The Socket.IO server instance
|
||||
*/
|
||||
function handleServerError(err) {
|
||||
console.error("WebSSH2 server.listen ERROR:", err.code)
|
||||
function setupSocketIOListeners(io) {
|
||||
socketHandler(io, config)
|
||||
}
|
||||
|
||||
// Don't start the server immediately, export the function instead
|
||||
|
|
|
@ -36,12 +36,10 @@ router.get('/host/:host', auth, function (req, res) {
|
|||
req.session.sshCredentials.host = host
|
||||
req.session.sshCredentials.port = port
|
||||
|
||||
// Sanitize the sshCredentials object before logging
|
||||
// Sanitize and log the sshCredentials object
|
||||
const sanitizedCredentials = sanitizeObject(
|
||||
JSON.parse(JSON.stringify(req.session.sshCredentials))
|
||||
);
|
||||
|
||||
// Log the sanitized credentials
|
||||
debug('/ssh//host/ Credentials: ', sanitizedCredentials);
|
||||
|
||||
handleConnection(req, res, { host: req.params.host })
|
||||
|
|
Loading…
Reference in a new issue