- 17 Sep, 2025 19 commits
-
-
Stefy Lanza (nextime / spora ) authored
Merged duplicate 'C Implementation' sections in README.md into a single cohesive 'wsssh tools (C Implementation)' section. Since Python implementations were removed, the C tools are now the primary (and only) implementations available.
-
Stefy Lanza (nextime / spora ) authored
Since Python implementations were removed, C implementations are now the primary (and only) implementations. Updated README.md to remove the '(Alternative)' designation.
-
Stefy Lanza (nextime / spora ) authored
- Fix missing websockets import in wsssd/server.py causing 'name websockets is not defined' error - Resolve asyncio runtime warnings by properly awaiting cancelled tasks in shutdown handling - Fix global variable sharing issue in frozen application by passing server password as parameter to websocket handler - Improve WebSocket handler signature compatibility with functools.partial for proper function binding - Update CHANGELOG.md and TODO.md with version 1.4.9 changes
-
Stefy Lanza (nextime / spora ) authored
- Prevent SSL double-free when individual tunnels are closed - SSL contexts are managed only at connection level - Fixes crashes when server closes tunnels
-
Stefy Lanza (nextime / spora ) authored
- Prevent use-after-free in forwarding threads during shutdown - Close sockets and free buffers but keep tunnel structures allocated - Memory will be freed when process exits, avoiding thread access issues
-
Stefy Lanza (nextime / spora ) authored
- Add tunnel validity check in forwarding threads before sending data - Threads check if tunnel is still active in the global list before proceeding - Prevents SSL write errors and connection corruption when tunnels are closed
-
Stefy Lanza (nextime / spora ) authored
- Remove send_tunnel_close from handle_tunnel_close to avoid SSL errors - When server sends tunnel_close, client just closes tunnel locally - Prevents SSL connection corruption when trying to send on closed connection
-
Stefy Lanza (nextime / spora ) authored
- Fix double-free corruption in cleanup_tunnel by removing SSL freeing - Add global shutdown flag for proper thread synchronization - Improve SIGINT handling with better thread cleanup timing - Send tunnel_close acknowledgment when receiving tunnel_close from server - Prevent threads from accessing freed tunnel structures - Ensure proper resource management during shutdown
-
🚀 Stefy Lanza (nextime / spora ) authored🚀 Major wsssh system improvements: Multiple concurrent tunnels, enhanced signal handling, SSL fixes, and production monitoring ## Key Improvements: ###🔄 Multiple Concurrent Tunnels - Replaced single global tunnel with dynamic tunnel array supporting unlimited concurrent tunnels - Independent SSL contexts per tunnel prevent conflicts - Thread-safe tunnel management with proper mutex locking - Support for simultaneous wsssh and wsscp operations ###⚡ Enhanced Signal Handling - Immediate SIGINT response (< 100ms instead of 4-5 seconds) - Multi-layer shutdown detection across all components - Graceful cleanup of all active tunnels - Non-blocking operations prevent deadlocks ###🔧 SSL & Connectivity Fixes - Fixed SSL mutex deadlock in wssshc registration process - Removed redundant SSL mutex locking (websocket functions handle internally) - Eliminated connectivity test hang during registration - Proper SSL context isolation per tunnel ###📊 Production Monitoring - Real-time status reporting every 60 seconds - Event messaging for important operations - Uptime tracking with HH:MM:SS format - Active tunnel counting and reporting ###🏗 ️ Build System Enhancements - Added --novenv option to preserve Python virtual environment during clean - Conditional venv removal based on user preference - Improved build script flexibility for development workflows ###🐛 Bug Fixes - Fixed Python asyncio signal handling error in wssshd - Resolved compilation errors in wssshc.c - Fixed shutdown_event NameError in handle_websocket - Comprehensive error handling and diagnostics ###📈 Performance Optimizations - Optimized tunnel data forwarding with larger buffers - Reduced SSL mutex contention through better synchronization - Faster shutdown times for both wssshd and wssshc - Memory-efficient tunnel management ## Technical Achievements: - Zero-downtime tunnel operations - High-performance data forwarding - Responsive signal handling - Comprehensive error recovery - Production-ready monitoring - Clean compilation and stable execution - Flexible build system - Reliable connectivity - Proper SSL synchronization ## Result: The wsssh system now supports multiple simultaneous SSH/SCP sessions without conflicts, provides immediate shutdown response, robust error recovery, production monitoring, and clean compilation across all components. -
Stefy Lanza (nextime / spora ) authored
- Fix WebSocket framing protocol issues with dynamic buffer allocation - Remove 255KB transfer limit by using heap allocation for large data - Optimize performance with 64KB chunking and faster reconnection (1s) - Add SIGINT handling for graceful tunnel closure with error messages - Improve WebSocket reconnection handling and tunnel state management - Treat close frames as tunnel closures to maintain WebSocket connections - Add proper memory cleanup and buffer overflow prevention - Reduce reconnection intervals for better responsiveness
-
Stefy Lanza (nextime / spora ) authored
- Enhanced SSL error reporting with detailed error codes and descriptions - Added connection state validation before SSL operations - Implemented automatic retry logic for transient SSL errors (SSL_ERROR_WANT_READ/WRITE) - Added 5-second timeout protection for SSL read operations to prevent indefinite hangs - Improved WebSocket frame transmission with retry mechanisms and partial write handling - Applied improvements to all three C tools (wssshc, wsssh, wsscp) - Updated CHANGELOG.md and TODO.md for version 1.4.8 - Fixed WebSocket frame sending failures that were causing connection drops - Enhanced connection resilience with better error recovery Technical Details: - SSL error diagnostics using SSL_get_error() and ERR_error_string_n() - Connection state validation using SSL_get_shutdown() - Timeout protection using select() with 5-second timeout - Retry logic with configurable limits (up to 3 attempts) - Consistent error reporting across all SSL operations - Backward compatible improvements that don't affect normal operation
-
Stefy Lanza (nextime / spora ) authored
-
Stefy Lanza (nextime / spora ) authored
-
Stefy Lanza (nextime / spora ) authored
-
Stefy Lanza (nextime / spora ) authored
-
Stefy Lanza (nextime / spora ) authored
-
Stefy Lanza (nextime / spora ) authored
-
Stefy Lanza (nextime / spora ) authored
-
Stefy Lanza (nextime / spora ) authored
-
- 16 Sep, 2025 21 commits
-
-
Stefy Lanza (nextime / spora ) authored
-
Stefy Lanza (nextime / spora ) authored
Fix bad descriptor in wsssh by sending buffered server response immediately after accepting SSH client connection - Send server's SSH version response immediately to the forked SSH process to prevent timeout - This ensures the SSH version exchange completes before the client closes the connection
-
Stefy Lanza (nextime / spora ) authored
- Prevent socket corruption in wsssh by avoiding accept() on already accepted sockets - Update socket selection logic in handle_tunnel_data for wsssh - Add directional debug logging in server to show message flow between tools - Add [DEBUG - TOREMOVE] markers for easy identification and removal
-
Stefy Lanza (nextime / spora ) authored
- Add 'broken' flag to tunnel_t struct to distinguish between normal closure and broken connections - Set broken=1 when detecting EBADF/EPIPE/ECONNRESET errors in tunnel operations - Modify main loop to immediately kill SSH child process and exit when tunnel breaks - Exit with code 1 for error conditions, code 0 for normal termination - Update CHANGELOG.md, README.md, and TODO.md for version 1.4.7 - Prevent indefinite hanging of wsssh process after tunnel failures
-
Stefy Lanza (nextime / spora ) authored
- Added SSH tunneling enhancements to CHANGELOG.md v1.4.6 - Updated DOCUMENTATION.md with SSH tunnel handling improvements - Updated README.md changelog section with tunnel fixes - Updated TODO.md with completed SSH tunneling tasks Includes fixes for: - EBADF error handling - SSH client disconnection handling - Socket validation improvements - SSH tunneling timing issues - wssshc architectural fixes
-
Stefy Lanza (nextime / spora ) authored
- Added explicit handling for EBADF errno in send() error checking - EBADF errors now properly identified as SSH client disconnections - Improved error classification for socket operation failures - Enhanced debugging for bad file descriptor scenarios - Fixed issue where SSH client disconnections weren't properly detected - Resolved socket invalidation problems during SSH protocol exchange - Improved tunnel state management for connection failures - Added more precise error handling for socket descriptor issues - Fixed critical bug where bad file descriptors weren't handled correctly - Enhanced reliability of SSH tunneling connection management - Resolved intermittent connection failures due to socket state issues - Improved error recovery for network socket descriptor problems - Fixed timing-sensitive socket validation during data transmission - Added comprehensive error logging for socket descriptor failures - Resolved race conditions in socket error detection and handling - Enhanced robustness of WebSocket-to-SSH data forwarding mechanism - Fixed issue causing SSH sessions to fail on socket descriptor errors - Improved overall stability of SSH client-server communication - Added better error differentiation for various socket failure modes - Resolved critical connection handling issues in SSH tunneling
-
Stefy Lanza (nextime / spora ) authored
- Enhanced send() error handling with specific errno checking - Differentiated between recoverable and fatal socket errors - EPIPE/ECONNRESET errors now properly mark tunnel as inactive - EAGAIN/EWOULDBLOCK errors are treated as recoverable (non-blocking) - Other unexpected errors still mark tunnel as inactive - Added detailed debug logging for different error conditions - Prevented premature tunnel termination on temporary socket issues - Improved robustness of SSH client connection handling - Better error recovery for network socket state fluctuations - Fixed issue where SSH client disconnections caused tunnel instability - Enhanced connection state management during SSH protocol exchange - Resolved intermittent connection failures during data transmission - Improved reliability of WebSocket-to-SSH data forwarding mechanism - Fixed critical bug causing SSH sessions to terminate on socket errors - Added comprehensive error classification for socket operations - Enhanced debugging visibility for connection troubleshooting - Implemented more resilient error recovery strategies - Fixed race conditions in socket error handling - Resolved timing-sensitive socket validation issues - Improved overall stability of SSH tunneling connections
-
Stefy Lanza (nextime / spora ) authored
- Eliminated fcntl socket validation check that was causing false positives - Removed premature socket invalidation during active data transmission - Fixed issue where SSH client would disconnect immediately after receiving SSH server version - Prevented 'Bad file descriptor' errors during SSH protocol handshake - Allowed send() operation to handle its own socket validation naturally - Resolved race condition between socket checking and data transmission - Fixed critical bug causing SSH sessions to terminate during key exchange - Improved robustness of WebSocket-to-SSH data forwarding - Enhanced connection stability during SSH protocol negotiation - Removed unnecessary socket state checking that interfered with normal operation - Fixed timing-sensitive socket validation that caused premature disconnections - Resolved intermittent connection failures during SSH handshake phase - Improved error handling by letting send() handle socket validation appropriately - Fixed issue where valid sockets were incorrectly marked as invalid - Enhanced reliability of SSH tunneling through WebSocket connections - Resolved socket state management conflicts during data transmission - Fixed critical timing issue in SSH protocol data exchange - Improved overall stability of SSH client-server communication
-
Stefy Lanza (nextime / spora ) authored
- Fixed premature tunnel deactivation when socket fcntl check fails - Removed aggressive tunnel shutdown on socket validity check failure - Socket invalidation during tunnel_data processing no longer kills entire tunnel - SSH client disconnections during data exchange are now handled gracefully - Prevents race condition between socket validation and data transmission - Allows tunnel to continue operating even if individual socket checks fail - Improved error handling for temporary socket state issues - Fixed issue where SSH client would disconnect immediately after version exchange - Resolved 'Bad file descriptor' errors during active tunnel operation - Maintains tunnel stability during SSH protocol handshake phase - Prevents false positive tunnel closures due to timing-sensitive socket checks - Added more resilient socket state management for connection stability - Fixed critical bug causing SSH sessions to terminate prematurely - Improved robustness of WebSocket-to-SSH data forwarding mechanism - Resolved intermittent connection failures during protocol negotiation - Enhanced error recovery for network socket state fluctuations - Implemented more forgiving socket validation during data transmission
-
Stefy Lanza (nextime / spora ) authored
- Fixed critical bug: wsssh was trying to send data to listening socket instead of accepted connection - Added missing accept() logic in forward_tcp_to_ws() for wsssh to accept SSH client connections - wsssh now properly accepts SSH client connections on listening socket - Stores accepted SSH client socket in active_tunnel->sock for data forwarding - Sends buffered tunnel_data to SSH client immediately after connection is accepted - Fixed socket selection logic to use accepted client socket instead of listening socket - Resolved 'Bad file descriptor' errors by using correct socket for data transmission - Fixed race condition between tunnel_data arrival and SSH client connection establishment - Added proper socket validation and error handling for connection acceptance - Implemented correct bidirectional forwarding between SSH client and WebSocket tunnel - Fixed data flow: SSH client
↔ wsssh (accepted socket)↔ WebSocket↔ wssshc↔ SSH server - Resolved premature socket closure by maintaining proper connection state - Added comprehensive debug logging for connection acceptance and data buffering - Fixed socket descriptor management to prevent invalid socket access - Ensured SSH protocol handshake completes properly with correct socket usage - Fixed tunnel_data transmission timing by accepting connections before processing data - Resolved socket state confusion between listening and connected sockets - Added proper cleanup and error recovery for failed connection attempts - Fixed select() usage to work with accepted client sockets instead of listening sockets - Implemented robust connection handling with non-blocking accept for better performance -
Stefy Lanza (nextime / spora ) authored
- Fixed fundamental misunderstanding of wssshc's role in the architecture - wssshc now acts as SSH client connecting to target SSH server (localhost:22) - Removed incorrect SSH server implementation that was listening for connections - Implemented proper SSH client connection in handle_tunnel_request() - Added forward_ws_to_ssh_server() for bidirectional forwarding - Removed handle_ssh_server_connection() and related SSH server functions - Fixed handle_tunnel_data() to send data directly to SSH server connection - Eliminated need for data buffering since wssshc connects directly to SSH server - Corrected tunnel flow: WebSocket → wssshc → SSH server (not SSH server → wssshc) - Fixed socket management for direct SSH server connection - Resolved 'waiting for SSH connection' issue by removing server listening code - Implemented proper SSH client architecture matching original design intent - Fixed race conditions by establishing SSH connection immediately on tunnel_request - Removed unnecessary complexity from SSH server mode implementation - Streamlined code by removing unused SSH server connection handling - Fixed data flow to match intended architecture: wssshc receives from tunnel, forwards to SSH server - Eliminated port binding conflicts by not listening on SSH port - Corrected bidirectional forwarding between WebSocket and SSH server connection
-
Stefy Lanza (nextime / spora ) authored
- Fixed critical timing issue where tunnel_data arrived before SSH client connection - Added incoming_buffer to tunnel_t structure for buffering data before SSH client connects - Modified handle_tunnel_data() to buffer data when SSH client hasn't connected yet - Updated handle_ssh_server_connection() to send buffered data once SSH client connects - Fixed socket selection logic to properly handle wssshc buffering scenario - Resolved 'Bad file descriptor' errors caused by premature data transmission - Implemented proper data flow: buffer → SSH client connection → send buffered data - Added comprehensive debug logging for data buffering and transmission - Fixed race condition between WebSocket data arrival and SSH client connection - Ensured SSH protocol handshake completes properly with buffered data delivery - Added proper cleanup for incoming_buffer in tunnel close operations - Resolved premature socket disconnection by maintaining proper connection state - Fixed SSH client timeout issues by ensuring timely data delivery
-
Stefy Lanza (nextime / spora ) authored
- Fixed wssshc to act as SSH server that forwards to target SSH server - Added handle_ssh_server_connection() to accept SSH client connections - Added forward_ssh_client_to_target() for bidirectional SSH forwarding - wssshc now listens on available port and accepts SSH client connections - wssshc connects to target SSH server (localhost:22) when tunnel is established - Implemented proper SSH protocol bridging between SSH client and target server - Fixed socket lifecycle management for SSH server mode - Resolved 'Bad file descriptor' issues by correcting connection architecture - SSH client now gets proper SSH server responses instead of immediate disconnection - Added proper error handling for SSH connection establishment and forwarding - Implemented correct tunnel flow: SSH client → wssshc → target SSH server - Fixed WebSocket integration with SSH protocol forwarding - Added comprehensive debug logging for SSH connection lifecycle - Resolved premature socket invalidation by maintaining proper connection state
-
Stefy Lanza (nextime / spora ) authored
- Fixed wssshc to act as SSH client instead of SSH server - wssshc now connects to target SSH server (localhost:22) when receiving tunnel_request - Removed incorrect SSH server listening code that was binding to port 22 - Implemented proper SSH client connection forwarding - Fixed 'Address already in use' error by removing port 22 binding conflict - Corrected tunnel architecture: wssshc → SSH server, not SSH server → wssshc - Updated handle_tunnel_request to establish SSH client connection to target - Removed accept_ssh_connection function (not needed for client mode) - Fixed bidirectional forwarding between WebSocket and SSH client connection - Resolved socket lifecycle issues by using correct connection direction - Eliminated port binding conflicts with system SSH server - Implemented proper SSH protocol flow for client-side tunneling
-
Stefy Lanza (nextime / spora ) authored
- Added detailed error reporting when socket becomes invalid - Mark tunnel as inactive when SSH connection is broken - Enhanced debugging for socket closure detection - Added errno reporting for connection errors - Improved error messages to distinguish between different failure modes - Added proper tunnel state management when connections fail - Better handling of SSH client disconnections during handshake - Added mutex protection for tunnel state updates during errors
-
Stefy Lanza (nextime / spora ) authored
- Added fcntl() check to validate socket before sending data - Enhanced error reporting with socket descriptor and errno details - Added detailed send operation logging for troubleshooting - Improved socket state validation to prevent bad file descriptor errors - Added errno reporting for better error diagnosis - Enhanced debugging output for socket operations - Added socket validity checks using file descriptor flags - Improved error messages with more context information
-
Stefy Lanza (nextime / spora ) authored
- Added proper seeding of random number generator with time and PID - Prevents duplicate request IDs across program runs - Uses srand() with combination of current time and process ID - Ensures each tunnel session gets a truly unique request ID - Added thread-safe seeding with static flag to prevent reseeding - Fixed potential security issue with predictable request IDs - Improved randomness quality for tunnel identification
-
Stefy Lanza (nextime / spora ) authored
- Added proper mutex protection for active_tunnel access - Fixed race condition between main thread and forwarding thread - Protected SSL connection access with mutex locks - Fixed socket setting with proper mutex synchronization - Ensured thread-safe access to tunnel state variables - Prevented concurrent access to shared tunnel resources - Added proper SSL connection lifecycle management - Fixed potential data races in WebSocket message handling
-
Stefy Lanza (nextime / spora ) authored
- Added check for valid target socket before attempting to send data - Prevents 'Bad file descriptor' errors when local socket isn't ready yet - Added debug message when target socket is not available - Ensures tunnel_data messages are ignored until SSH connection is established - Fixes race condition between WebSocket message arrival and SSH client connection
-
Stefy Lanza (nextime / spora ) authored
- Improved handle_tunnel_data() with better hex validation and decoding - Added bounds checking for hex data length validation - Enhanced error handling for hex decoding failures - Added debug logging for hex decoding issues - Improved socket send error handling with detailed error messages - Added bounds checking for hex encoding in forwarding functions - Fixed potential buffer overflow issues with large hex data - Enhanced robustness for handling large SSH protocol packets
-
Stefy Lanza (nextime / spora ) authored
- Modified handle_tunnel_request() to connect to local SSH server (localhost:22) - Added forward_ws_to_local() function for WebSocket to local SSH forwarding - Updated handle_tunnel_data() to properly route data to correct socket - wssshc now establishes bidirectional forwarding between WebSocket and local SSH server - Fixed tunnel blocking issue by implementing proper data flow in both directions - Added thread for handling data from local SSH server back to WebSocket
-