mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
autoconnect remotes
This commit is contained in:
@@ -272,8 +272,13 @@ func resolveUiIds(ctx context.Context, pk *scpacket.FeCommandPacketType, rtype i
|
||||
if !rtn.Remote.RState.IsConnected() {
|
||||
err = rtn.Remote.MShell.TryAutoConnect()
|
||||
if err != nil {
|
||||
return rtn, fmt.Errorf("error trying to auto-connect remote %q", rtn.Remote.DisplayName)
|
||||
return rtn, fmt.Errorf("error trying to auto-connect remote %q: %w", rtn.Remote.DisplayName, err)
|
||||
}
|
||||
rrNew, err := resolveRemoteFromPtr(ctx, rptr, rtn.SessionId, rtn.WindowId)
|
||||
if err != nil {
|
||||
return rtn, err
|
||||
}
|
||||
rtn.Remote = rrNew
|
||||
}
|
||||
if !rtn.Remote.RState.IsConnected() {
|
||||
return rtn, fmt.Errorf("remote %q is not connected", rtn.Remote.DisplayName)
|
||||
|
||||
@@ -1828,13 +1828,13 @@ func (msh *MShellProc) TryAutoConnect() error {
|
||||
return nil
|
||||
}
|
||||
rcopy := msh.GetRemoteCopy()
|
||||
if !rcopy.AutoInstall {
|
||||
if rcopy.ConnectMode == sstore.ConnectModeManual {
|
||||
return nil
|
||||
}
|
||||
var err error
|
||||
msh.WithLock(func() {
|
||||
if msh.NumTryConnect > 5 {
|
||||
err = fmt.Errorf("cannot auto-connect remote %q (too many unsuccessful tries)", msh.Remote.GetName())
|
||||
err = fmt.Errorf("too many unsuccessful tries")
|
||||
return
|
||||
}
|
||||
msh.NumTryConnect++
|
||||
@@ -1843,5 +1843,8 @@ func (msh *MShellProc) TryAutoConnect() error {
|
||||
return err
|
||||
}
|
||||
msh.Launch()
|
||||
if !msh.IsConnected() {
|
||||
return fmt.Errorf("error connecting")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user