autoconnect remotes

This commit is contained in:
sawka
2022-12-28 16:59:54 -08:00
parent 16b808bb21
commit e1e1a52e06
2 changed files with 11 additions and 3 deletions
+6 -1
View File
@@ -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)
+5 -2
View File
@@ -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
}