diff --git a/backend/server.js b/backend/server.js index 56bf24c8..30741345 100644 --- a/backend/server.js +++ b/backend/server.js @@ -67,6 +67,8 @@ wss.on('connection', (ws) => { port: 22, // Default SSH port username: data.username, // Username provided from the client password: data.password, // Password provided from the client + keepaliveInterval: 15000, // Send keep-alive packets every 15 seconds + keepaliveCountMax: 3, // Retry keep-alive 3 times before disconnecting }); } } catch (error) { diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 3b7bf407..58d7efe5 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -25,75 +25,57 @@ const App = () => { }, macOptionIsMeta: true, allowProposedApi: true, - scrollback: 1000, // Allow scrollback so the terminal doesn't lose state }); - // Initialize and attach the fit addon to the terminal fitAddon.current = new FitAddon(); terminal.current.loadAddon(fitAddon.current); terminal.current.open(terminalRef.current); - // Resize terminal to fit the container initially - fitAddon.current.fit(); - - // Adjust terminal size on window resize - const resizeListener = () => { - fitAddon.current.fit(); - }; - window.addEventListener('resize', resizeListener); - - // Monitor terminal data (activity) terminal.current.onData((data) => { if (socket.current && socket.current.readyState === WebSocket.OPEN) { socket.current.send(data); } }); - // Add specific resize call for certain programs like nano or vim - const resizeTerminalOnStart = () => { - // Resize immediately after starting vim/nano or other programs + // Resize terminal to fit the container initially + const resizeTerminal = () => { fitAddon.current.fit(); - terminal.current.clear(); }; + resizeTerminal(); - terminal.current.onData((data) => { - if (data.includes('nano') || data.includes('vim')) { - // Trigger resize immediately when these programs start - resizeTerminalOnStart(); - } - }); + // Adjust terminal size on window resize + window.addEventListener('resize', resizeTerminal); - // Cleanup on component unmount return () => { terminal.current.dispose(); if (socket.current) { socket.current.close(); } - window.removeEventListener('resize', resizeListener); + window.removeEventListener('resize', resizeTerminal); }; }, []); const handleConnect = () => { const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; - const wsUrl = `${protocol}//${window.location.host}/ws/`; // Use current host and "/ws/" endpoint - + const wsUrl = `${protocol}//${window.location.host}/ws/`; + socket.current = new WebSocket(wsUrl); - + socket.current.onopen = () => { terminal.current.writeln(`Connected to WebSocket server at ${wsUrl}`); socket.current.send(JSON.stringify({ host, username, password })); setIsConnected(true); }; - + socket.current.onmessage = (event) => { terminal.current.write(event.data); }; - + socket.current.onerror = (error) => { terminal.current.writeln(`WebSocket error: ${error.message}`); }; - + socket.current.onclose = () => { terminal.current.writeln('Disconnected from WebSocket server.'); setIsConnected(false); @@ -139,11 +121,7 @@ const App = () => {
- {/* Hide button always positioned in the bottom-right corner */} - diff --git a/info.txt b/info.txt index 17810552..6f2c2d46 100644 --- a/info.txt +++ b/info.txt @@ -1,7 +1,6 @@ Currently: Fix issue after nano where the input no longer goes down to the bottom. Fix issue where SSH randomly disconnects -Post inital build. Overall Features: SSH/RDP(?)/VNC(?)