diff --git a/app/client/src/js/index.ts b/app/client/src/js/index.ts index 12c61d6..e49026d 100644 --- a/app/client/src/js/index.ts +++ b/app/client/src/js/index.ts @@ -13,25 +13,9 @@ require('@xterm/xterm/css/xterm.css'); require('../css/style.css'); /* global Blob, logBtn, credentialsBtn, reauthBtn, downloadLogBtn */ // eslint-disable-line -let sessionLogEnable = false; -let loggedData = false; -let sessionLog: string; -let sessionFooter: any; -let logDate: { - getFullYear: () => any; - getMonth: () => number; - getDate: () => any; - getHours: () => any; - getMinutes: () => any; - getSeconds: () => any; -}; -let currentDate: Date; -let myFile: string; let errorExists: boolean; const term = new Terminal(); // DOM properties -const logBtn = document.getElementById('logBtn'); -const downloadLogBtn = document.getElementById('downloadLogBtn'); const status = document.getElementById('status'); const fitAddon = new FitAddon(); const terminalContainer = document.getElementById('terminal-container'); @@ -62,67 +46,6 @@ const socket = io({ }, }); -// cross browser method to "download" an element to the local system -// used for our client-side logging feature -function downloadLog() { - // eslint-disable-line - if (loggedData === true) { - myFile = `WebSSH2-${logDate.getFullYear()}${ - logDate.getMonth() + 1 - }${logDate.getDate()}_${logDate.getHours()}${logDate.getMinutes()}${logDate.getSeconds()}.log`; - // regex should eliminate escape sequences from being logged. - const blob = new Blob( - [ - sessionLog.replace( - // eslint-disable-next-line no-control-regex - /[\u001b\u009b][[\]()#;?]*(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><;]/g, - '', - ), - ], - { - // eslint-disable-line no-control-regex - type: 'text/plain', - }, - ); - const elem = window.document.createElement('a'); - elem.href = window.URL.createObjectURL(blob); - elem.download = myFile; - document.body.appendChild(elem); - elem.click(); - document.body.removeChild(elem); - } - term.focus(); -} -// Set variable to toggle log data from client/server to a varialble -// for later download -function toggleLog() { - // eslint-disable-line - if (sessionLogEnable === true) { - sessionLogEnable = false; - loggedData = true; - logBtn.innerHTML = ' Start Log'; - currentDate = new Date(); - sessionLog = `${sessionLog}\r\n\r\nLog End for ${sessionFooter}: ${currentDate.getFullYear()}/${ - currentDate.getMonth() + 1 - }/${currentDate.getDate()} @ ${currentDate.getHours()}:${currentDate.getMinutes()}:${currentDate.getSeconds()}\r\n`; - logDate = currentDate; - term.focus(); - return false; - } - sessionLogEnable = true; - loggedData = true; - logBtn.innerHTML = ' Stop Log'; - downloadLogBtn.style.color = '#000'; - downloadLogBtn.addEventListener('click', downloadLog); - currentDate = new Date(); - sessionLog = `Log Start for ${sessionFooter}: ${currentDate.getFullYear()}/${ - currentDate.getMonth() + 1 - }/${currentDate.getDate()} @ ${currentDate.getHours()}:${currentDate.getMinutes()}:${currentDate.getSeconds()}\r\n\r\n`; - logDate = currentDate; - term.focus(); - return false; -} - function resizeScreen() { fitAddon.fit(); socket.emit('resize', { cols: term.cols, rows: term.rows }); @@ -137,9 +60,6 @@ term.onData((data) => { socket.on('data', (data: string | Uint8Array) => { term.write(data); - if (sessionLogEnable) { - sessionLog += data; - } }); socket.on('connect', () => { @@ -171,23 +91,3 @@ socket.on('disconnect', (err: any) => { // status.innerHTML = `ERROR: ${err}`; // } // }); - -// socket.on('reauth', () => { -// if (allowreauth) { -// reauthSession(); -// } -// }); - -// safe shutdown - -// socket.on('shutdownCountdownUpdate', (remainingSeconds: any) => { -// if (!hasCountdownStarted) { -// countdown.classList.add('active'); -// hasCountdownStarted = true; -// } -// countdown.innerText = `Shutting down in ${remainingSeconds}s`; -// }); - -// term.onTitleChange((title) => { -// document.title = title; -// }); diff --git a/app/server/app.js b/app/server/app.js index 48153af..431da4f 100644 --- a/app/server/app.js +++ b/app/server/app.js @@ -40,13 +40,13 @@ function startServer() { app.disable('x-powered-by'); app.use(express.urlencoded({ extended: true })); - app.post('/ssh/host/:host?', connectTerminalWS); + app.post('/ssh/devbox/', connectTerminalWS); // ======== To remove ======== // Static files.. app.post('/ssh', express.static(publicPath, staticFileConfig)); app.use('/ssh', express.static(publicPath, staticFileConfig)); // =========================== - app.get('/ssh/host/:host?', connectTerminalWS); + app.get('/ssh/devbox/', connectTerminalWS); io.on('connection', appSocket);