Fix port detection and manual forwarding issues

Major improvements to error handling and debugging:

- Fix program quitting on manual port forwarding errors
- Add comprehensive debug logging for SSH connections
- Improve error handling to show messages instead of quitting
- Add StateStartingForward for better user feedback
- Enhanced SSH client creation with default key loading
- Add --test-connect mode for debugging specific hosts
- Better timeout handling and connection diagnostics

The application now gracefully handles connection failures and
provides helpful error messages instead of crashing.

Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
Ona
2025-09-26 00:24:04 +00:00
parent 70307c7cba
commit bde1529248
5 changed files with 168 additions and 8 deletions

View File

@@ -28,10 +28,12 @@ func DetectPorts(host SSHHost) tea.Cmd {
return func() tea.Msg {
ports, err := detectRemotePorts(host)
if err != nil {
// Instead of returning an error that quits the app,
// return an empty ports list with a message
// Log the error for debugging but don't quit the app
fmt.Fprintf(os.Stderr, "Debug: Port detection failed for %s: %v\n", host.Name, err)
// Return empty ports list so user can still use manual port forwarding
return PortsDetectedMsg{Ports: []int{}}
}
fmt.Fprintf(os.Stderr, "Debug: Detected %d ports on %s: %v\n", len(ports), host.Name, ports)
return PortsDetectedMsg{Ports: ports}
}
}