fix: enable autoConnect only on /ssh/host/

This commit is contained in:
Bill Church 2024-08-19 11:36:34 +00:00
parent 9cfccb109a
commit c9591d637d
No known key found for this signature in database

View file

@ -1,13 +1,13 @@
// server // server
// app/connectionHandler.js // app/connectionHandler.js
const createDebug = require("debug") const createDebug = require('debug')
var path = require("path") const path = require('path')
var fs = require("fs") const fs = require('fs')
var extend = require("util")._extend const extend = require('util')._extend
const debug = createDebug("webssh2:connectionHandler") const debug = createDebug('webssh2:connectionHandler')
function handleConnection(req, res, urlParams) { function handleConnection(req, res, urlParams) {
debug("Handling connection") debug('Handling connection')
urlParams = urlParams || {} urlParams = urlParams || {}
const clientPath = path.resolve( const clientPath = path.resolve(
@ -24,7 +24,12 @@ function handleConnection(req, res, urlParams) {
url: req.protocol + '://' + req.get('host'), url: req.protocol + '://' + req.get('host'),
path: '/ssh/socket.io' path: '/ssh/socket.io'
}, },
autoConnect: true autoConnect: false // Default to false
}
// Check if the current route is /host/:host
if (req.path.startsWith('/ssh/host/')) {
tempConfig.autoConnect = true
} }
fs.readFile( fs.readFile(