From eb00fde596090a3ad28426a7d4d1697252e86412 Mon Sep 17 00:00:00 2001 From: sawka Date: Wed, 21 Sep 2022 23:26:24 -0700 Subject: [PATCH] send uname/mshellversion with remotestate --- pkg/cmdrunner/cmdrunner.go | 14 -------------- pkg/remote/remote.go | 13 +++++++++++++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/pkg/cmdrunner/cmdrunner.go b/pkg/cmdrunner/cmdrunner.go index 74cd4309..405cf070 100644 --- a/pkg/cmdrunner/cmdrunner.go +++ b/pkg/cmdrunner/cmdrunner.go @@ -553,20 +553,6 @@ func RemoteShowCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (s return nil, err } state := ids.Remote.RState - var buf bytes.Buffer - buf.WriteString(fmt.Sprintf(" %-15s %s\n", "type", state.RemoteType)) - buf.WriteString(fmt.Sprintf(" %-15s %s\n", "remoteid", state.RemoteId)) - buf.WriteString(fmt.Sprintf(" %-15s %s\n", "physicalid", state.PhysicalId)) - buf.WriteString(fmt.Sprintf(" %-15s %s\n", "alias", state.RemoteAlias)) - buf.WriteString(fmt.Sprintf(" %-15s %s\n", "canonicalname", state.RemoteCanonicalName)) - buf.WriteString(fmt.Sprintf(" %-15s %s\n", "connectmode", state.ConnectMode)) - buf.WriteString(fmt.Sprintf(" %-15s %s\n", "status", state.Status)) - if ids.Remote.RemoteState != nil { - buf.WriteString(fmt.Sprintf(" %-15s %s\n", "cwd", ids.Remote.RemoteState.Cwd)) - } - if state.ErrorStr != "" { - buf.WriteString(fmt.Sprintf(" %-15s %s\n", "error", state.ErrorStr)) - } return sstore.ModelUpdate{ Info: &sstore.InfoMsgType{ InfoTitle: fmt.Sprintf("show remote [%s] info", ids.Remote.DisplayName), diff --git a/pkg/remote/remote.go b/pkg/remote/remote.go index 2bb9b0a8..809524a1 100644 --- a/pkg/remote/remote.go +++ b/pkg/remote/remote.go @@ -90,6 +90,8 @@ type RemoteRuntimeState struct { ConnectMode string `json:"connectmode"` Archived bool `json:"archived"` RemoteIdx int64 `json:"remoteidx"` + UName string `json:"uname"` + MShellVersion string `json:"mshellversion"` } func (state RemoteRuntimeState) IsConnected() bool { @@ -349,6 +351,7 @@ func (msh *MShellProc) GetRemoteRuntimeState() RemoteRuntimeState { ConnectMode: msh.Remote.ConnectMode, Archived: msh.Remote.Archived, RemoteIdx: msh.Remote.RemoteIdx, + UName: msh.UName, } if msh.Err != nil { state.ErrorStr = msh.Err.Error() @@ -376,6 +379,7 @@ func (msh *MShellProc) GetRemoteRuntimeState() RemoteRuntimeState { Cwd: msh.ServerProc.InitPk.Cwd, Env0: msh.ServerProc.InitPk.Env0, } + state.MShellVersion = msh.ServerProc.InitPk.Version vars["home"] = msh.ServerProc.InitPk.HomeDir vars["remoteuser"] = msh.ServerProc.InitPk.User vars["bestuser"] = vars["remoteuser"] @@ -517,6 +521,12 @@ func (msh *MShellProc) GetRemoteCopy() sstore.RemoteType { return *msh.Remote } +func (msh *MShellProc) GetUName() string { + msh.Lock.Lock() + defer msh.Lock.Unlock() + return msh.UName +} + func (msh *MShellProc) GetNumRunningCommands() int { msh.Lock.Lock() defer msh.Lock.Unlock() @@ -642,6 +652,9 @@ func (msh *MShellProc) Launch() { msh.WithLock(func() { msh.UName = uname msh.MakeClientCancelFn = nil + if cproc != nil && cproc.InitPk != nil { + msh.Remote.InitPk = cproc.InitPk + } // no notify here, because we'll call notify in either case below }) if err == context.Canceled {