Nano and timeout error fix #1

This commit is contained in:
LukeGus
2024-12-04 21:19:30 -06:00
parent b6a3f881a8
commit 1139160e48
3 changed files with 15 additions and 36 deletions

View File

@@ -67,6 +67,8 @@ wss.on('connection', (ws) => {
port: 22, // Default SSH port port: 22, // Default SSH port
username: data.username, // Username provided from the client username: data.username, // Username provided from the client
password: data.password, // Password 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) { } catch (error) {

View File

@@ -25,58 +25,40 @@ const App = () => {
}, },
macOptionIsMeta: true, macOptionIsMeta: true,
allowProposedApi: 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(); fitAddon.current = new FitAddon();
terminal.current.loadAddon(fitAddon.current); terminal.current.loadAddon(fitAddon.current);
terminal.current.open(terminalRef.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) => { terminal.current.onData((data) => {
if (socket.current && socket.current.readyState === WebSocket.OPEN) { if (socket.current && socket.current.readyState === WebSocket.OPEN) {
socket.current.send(data); socket.current.send(data);
} }
}); });
// Add specific resize call for certain programs like nano or vim // Resize terminal to fit the container initially
const resizeTerminalOnStart = () => { const resizeTerminal = () => {
// Resize immediately after starting vim/nano or other programs
fitAddon.current.fit(); fitAddon.current.fit();
terminal.current.clear();
}; };
resizeTerminal();
terminal.current.onData((data) => { // Adjust terminal size on window resize
if (data.includes('nano') || data.includes('vim')) { window.addEventListener('resize', resizeTerminal);
// Trigger resize immediately when these programs start
resizeTerminalOnStart();
}
});
// Cleanup on component unmount
return () => { return () => {
terminal.current.dispose(); terminal.current.dispose();
if (socket.current) { if (socket.current) {
socket.current.close(); socket.current.close();
} }
window.removeEventListener('resize', resizeListener); window.removeEventListener('resize', resizeTerminal);
}; };
}, []); }, []);
const handleConnect = () => { const handleConnect = () => {
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; 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 = new WebSocket(wsUrl);
@@ -139,11 +121,7 @@ const App = () => {
<div ref={terminalRef} className="terminal-container"></div> <div ref={terminalRef} className="terminal-container"></div>
</div> </div>
{/* Hide button always positioned in the bottom-right corner */} <button className="hide-sidebar-button" onClick={handleSideBarHiding}>
<button
className="hide-sidebar-button"
onClick={handleSideBarHiding}
>
{isSideBarHidden ? '+' : '-'} {isSideBarHidden ? '+' : '-'}
</button> </button>
</div> </div>

View File

@@ -1,7 +1,6 @@
Currently: Currently:
Fix issue after nano where the input no longer goes down to the bottom. Fix issue after nano where the input no longer goes down to the bottom.
Fix issue where SSH randomly disconnects Fix issue where SSH randomly disconnects
Post inital build.
Overall Features: Overall Features:
SSH/RDP(?)/VNC(?) SSH/RDP(?)/VNC(?)