1. 17 Sep, 2025 23 commits
  2. 16 Sep, 2025 17 commits
    • Stefy Lanza (nextime / spora )'s avatar
    • Stefy Lanza (nextime / spora )'s avatar
      Fix bad descriptor in wsssh by sending buffered server response immediately... · 4c7f1350
      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
      4c7f1350
    • Stefy Lanza (nextime / spora )'s avatar
      Fix bad descriptor in wsssh tunnel and add directional logging · 9356f699
      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
      9356f699
    • Stefy Lanza (nextime / spora )'s avatar
      Fix critical wsssh process hanging issue after SSH client disconnection · a1300943
      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
      a1300943
    • Stefy Lanza (nextime / spora )'s avatar
      Update documentation for SSH tunneling improvements · d6ee31e9
      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
      d6ee31e9
    • Stefy Lanza (nextime / spora )'s avatar
      Add specific handling for EBADF (Bad file descriptor) errors · d5f498c2
      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
      d5f498c2
    • Stefy Lanza (nextime / spora )'s avatar
      Improve error handling in handle_tunnel_data for SSH client disconnections · cd3ecbb1
      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
      cd3ecbb1
    • Stefy Lanza (nextime / spora )'s avatar
      Remove aggressive socket validation causing SSH client disconnections · e834e7eb
      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
      e834e7eb
    • Stefy Lanza (nextime / spora )'s avatar
      Fix SSH client socket invalidation issue in handle_tunnel_data · 6a497894
      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
      6a497894
    • Stefy Lanza (nextime / spora )'s avatar
      Fix wsssh socket handling - add missing SSH client accept() logic · 4165730c
      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
      4165730c
    • Stefy Lanza (nextime / spora )'s avatar
      Correct wssshc architecture - wssshc acts as SSH client, not SSH server · 5a1b73b4
      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
      5a1b73b4
    • Stefy Lanza (nextime / spora )'s avatar
      Fix SSH tunneling timing issue with proper data buffering · 31c7eed6
      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
      31c7eed6
    • Stefy Lanza (nextime / spora )'s avatar
      Implement correct SSH tunneling architecture for wssshc · 14eef6e4
      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
      14eef6e4
    • Stefy Lanza (nextime / spora )'s avatar
      Fix critical architectural issue in wssshc tunnel handling · 0ecabb18
      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
      0ecabb18
    • Stefy Lanza (nextime / spora )'s avatar
      Improve error handling for broken SSH connections · 3fbae822
      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
      3fbae822
    • Stefy Lanza (nextime / spora )'s avatar
      Add enhanced socket debugging and validation · 0ca61906
      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
      0ca61906
    • Stefy Lanza (nextime / spora )'s avatar
      Fix request ID generation to ensure uniqueness · 891795a3
      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
      891795a3