diff --git a/pkg/remote/remote.go b/pkg/remote/remote.go index 1129b949..225c5f72 100644 --- a/pkg/remote/remote.go +++ b/pkg/remote/remote.go @@ -97,6 +97,7 @@ type MShellProc struct { ServerProc *shexec.ClientProc UName string Err error + ErrNoInitPk bool ControllingPty *os.File PtyBuffer *circbuf.Buffer MakeClientCancelFn context.CancelFunc @@ -135,6 +136,8 @@ type RemoteRuntimeState struct { InstallStatus string `json:"installstatus"` InstallErrorStr string `json:"installerrorstr,omitempty"` NeedsMShellUpgrade bool `json:"needsmshellupgrade,omitempty"` + NoInitPk bool `json:"noinitpk,omitempty"` + AuthType string `json:"authtype,omitempty"` ConnectMode string `json:"connectmode"` AutoInstall bool `json:"autoinstall"` Archived bool `json:"archived,omitempty"` @@ -513,6 +516,11 @@ func (msh *MShellProc) GetRemoteRuntimeState() RemoteRuntimeState { InstallStatus: msh.InstallStatus, NeedsMShellUpgrade: msh.NeedsMShellUpgrade, Local: msh.Remote.Local, + NoInitPk: msh.ErrNoInitPk, + AuthType: sstore.RemoteAuthTypeNone, + } + if msh.Remote.SSHOpts != nil { + state.AuthType = msh.Remote.SSHOpts.GetAuthType() } if msh.Remote.RemoteOpts != nil { optsCopy := *msh.Remote.RemoteOpts @@ -1135,6 +1143,7 @@ func (msh *MShellProc) Launch(interactive bool) { defer makeClientCancelFn() msh.WithLock(func() { msh.Err = nil + msh.ErrNoInitPk = false msh.Status = StatusConnecting msh.MakeClientCancelFn = makeClientCancelFn go msh.NotifyRemoteUpdate() @@ -1145,6 +1154,9 @@ func (msh *MShellProc) Launch(interactive bool) { var stateBaseHash string msh.WithLock(func() { msh.MakeClientCancelFn = nil + if initPk == nil { + msh.ErrNoInitPk = true + } if initPk != nil { msh.UName = initPk.UName mshellVersion = initPk.Version diff --git a/pkg/sstore/sstore.go b/pkg/sstore/sstore.go index 7963ae31..6715ce39 100644 --- a/pkg/sstore/sstore.go +++ b/pkg/sstore/sstore.go @@ -54,6 +54,13 @@ const ( CmdStatusWaiting = "waiting" ) +const ( + RemoteAuthTypeNone = "none" + RemoteAuthTypePassword = "password" + RemoteAuthTypeKey = "key" + RemoteAuthTypeKeyPassword = "key+password" +) + const ( ShareModeLocal = "local" ShareModeWeb = "web" @@ -793,6 +800,19 @@ type SSHOpts struct { SSHPassword string `json:"sshpassword,omitempty"` } +func (opts SSHOpts) GetAuthType() string { + if opts.SSHPassword != "" && opts.SSHIdentity != "" { + return RemoteAuthTypeKeyPassword + } + if opts.SSHIdentity != "" { + return RemoteAuthTypeKey + } + if opts.SSHPassword != "" { + return RemoteAuthTypePassword + } + return RemoteAuthTypeNone +} + type RemoteOptsType struct { Color string `json:"color"` }