send uname/mshellversion with remotestate

This commit is contained in:
sawka
2022-09-21 23:26:24 -07:00
parent 21617298e9
commit eb00fde596
2 changed files with 13 additions and 14 deletions
-14
View File
@@ -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),
+13
View File
@@ -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 {