mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-09-05 08:37:25 -04:00
Fix crash for SSH dialing errors on interactive clients
This commit is contained in:
@@ -101,6 +101,7 @@ func GetSSHClient(manualSync bool) (*ssh.Client, string, bool) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(core.AnsiError+"Sync failed - Unable to connect to remote server:", err.Error()+core.AnsiReset)
|
fmt.Println(core.AnsiError+"Sync failed - Unable to connect to remote server:", err.Error()+core.AnsiReset)
|
||||||
core.Exit(core.ErrorServerConnection) // do not close/crash interactive clients
|
core.Exit(core.ErrorServerConnection) // do not close/crash interactive clients
|
||||||
|
return nil, "", false
|
||||||
}
|
}
|
||||||
|
|
||||||
return sshClient, entryRoot, isWindows
|
return sshClient, entryRoot, isWindows
|
||||||
@@ -447,6 +448,9 @@ func folderSync(folders []string) {
|
|||||||
func RunJob(manualSync, returnLists bool) [3][]string {
|
func RunJob(manualSync, returnLists bool) [3][]string {
|
||||||
// get SSH client to re-use throughout the sync process
|
// get SSH client to re-use throughout the sync process
|
||||||
sshClient, sshEntryRoot, sshIsWindows := GetSSHClient(manualSync)
|
sshClient, sshEntryRoot, sshIsWindows := GetSSHClient(manualSync)
|
||||||
|
if sshClient == nil { // indicate SSH dialing failure for interactive clients
|
||||||
|
return [3][]string{nil, nil, nil}
|
||||||
|
}
|
||||||
defer func(sshClient *ssh.Client) {
|
defer func(sshClient *ssh.Client) {
|
||||||
err := sshClient.Close()
|
err := sshClient.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user