add two new fields to remotetype for better messages on client

This commit is contained in:
sawka
2023-04-03 01:37:55 -07:00
parent 59fd629920
commit 0a16bb2181
2 changed files with 32 additions and 0 deletions
+12
View File
@@ -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
+20
View File
@@ -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"`
}