mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
Rename Waveshell First Pass (#632)
This begins the process of renaming mshell to waveshell everywhere by making the most simple changes. There will need to be additional changes in the future, but the hope is to merge simple changes in now to reduce the number of future merge conflicts.
This commit is contained in:
parent
cd855762cd
commit
167277ec11
@ -140,12 +140,12 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
|
||||
renderInstallStatus(remote: RemoteType): any {
|
||||
let statusStr: string = null;
|
||||
if (remote.installstatus == "disconnected") {
|
||||
if (remote.needsmshellupgrade) {
|
||||
statusStr = "mshell " + remote.mshellversion + " - needs upgrade";
|
||||
} else if (util.isBlank(remote.mshellversion)) {
|
||||
statusStr = "mshell unknown";
|
||||
if (remote.needswaveshellupgrade) {
|
||||
statusStr = "waveshell " + remote.waveshellversion + " - needs upgrade";
|
||||
} else if (util.isBlank(remote.waveshellversion)) {
|
||||
statusStr = "waveshell unknown";
|
||||
} else {
|
||||
statusStr = "mshell " + remote.mshellversion + " - current";
|
||||
statusStr = "waveshell " + remote.waveshellversion + " - current";
|
||||
}
|
||||
} else {
|
||||
statusStr = remote.installstatus;
|
||||
@ -231,7 +231,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
|
||||
} else if (remote.status == "disconnected") {
|
||||
buttons.push(connectButton);
|
||||
} else if (remote.status == "error") {
|
||||
if (remote.needsmshellupgrade) {
|
||||
if (remote.needswaveshellupgrade) {
|
||||
if (remote.installstatus == "connecting") {
|
||||
buttons.push(cancelInstallButton);
|
||||
} else {
|
||||
@ -270,7 +270,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
|
||||
} else if (remote.status == "error") {
|
||||
if (remote.noinitpk) {
|
||||
message = "Error, could not connect.";
|
||||
} else if (remote.needsmshellupgrade) {
|
||||
} else if (remote.needswaveshellupgrade) {
|
||||
if (remote.installstatus == "connecting") {
|
||||
message = "Installing...";
|
||||
} else {
|
||||
|
4
src/types/custom.d.ts
vendored
4
src/types/custom.d.ts
vendored
@ -121,8 +121,8 @@ declare global {
|
||||
sshconfigsrc: string;
|
||||
archived: boolean;
|
||||
uname: string;
|
||||
mshellversion: string;
|
||||
needsmshellupgrade: boolean;
|
||||
waveshellversion: string;
|
||||
needswaveshellupgrade: boolean;
|
||||
noinitpk: boolean;
|
||||
authtype: string;
|
||||
waitingforpassword: boolean;
|
||||
|
@ -28,7 +28,7 @@ func readFullRunPacket(packetParser *packet.PacketParser) (*packet.RunPacketType
|
||||
return runPacket, nil
|
||||
}
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid packet '%s' sent to mshell", pk.GetType())
|
||||
return nil, fmt.Errorf("invalid packet '%s' sent to waveshell", pk.GetType())
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("no run packet received")
|
||||
@ -97,7 +97,7 @@ func handleSingle() {
|
||||
|
||||
func handleUsage() {
|
||||
usage := `
|
||||
mshell is a helper program for wave terminal. it is used to execute commands
|
||||
waveshell is a helper program for wave terminal. it is used to execute commands
|
||||
|
||||
Options:
|
||||
--help - prints this message
|
||||
@ -106,7 +106,7 @@ Options:
|
||||
--single - run a single command (connected to multiplexer)
|
||||
--single --version - return an init packet with version info
|
||||
|
||||
mshell does not open any external ports and does not require any additional permissions.
|
||||
waveshell does not open any external ports and does not require any additional permissions.
|
||||
it communicates exclusively through stdin/stdout with an attached process
|
||||
via a JSON packet format.
|
||||
`
|
||||
@ -124,7 +124,7 @@ func main() {
|
||||
handleUsage()
|
||||
return
|
||||
} else if firstArg == "--version" {
|
||||
fmt.Printf("mshell %s+%s\n", base.MShellVersion, base.BuildTime)
|
||||
fmt.Printf("waveshell %s+%s\n", base.WaveshellVersion, base.BuildTime)
|
||||
return
|
||||
} else if firstArg == "--single" || firstArg == "--single-from-server" {
|
||||
base.ProcessType = base.ProcessType_WaveShellSingle
|
||||
|
@ -20,18 +20,18 @@ import (
|
||||
)
|
||||
|
||||
const HomeVarName = "HOME"
|
||||
const DefaultMShellHome = "~/.mshell"
|
||||
const DefaultMShellName = "mshell"
|
||||
const MShellPathVarName = "MSHELL_PATH"
|
||||
const MShellHomeVarName = "MSHELL_HOME"
|
||||
const MShellInstallBinVarName = "MSHELL_INSTALLBIN_PATH"
|
||||
const DefaultWaveshellHome = "~/.mshell"
|
||||
const DefaultWaveshellName = "mshell"
|
||||
const WaveshellPathVarName = "MSHELL_PATH"
|
||||
const WaveshellHomeVarName = "MSHELL_HOME"
|
||||
const WaveshellInstallBinVarName = "MSHELL_INSTALLBIN_PATH"
|
||||
const SSHCommandVarName = "SSH_COMMAND"
|
||||
const MShellDebugVarName = "MSHELL_DEBUG"
|
||||
const WaveshellDebugVarName = "MSHELL_DEBUG"
|
||||
const SessionsDirBaseName = "sessions"
|
||||
const RcFilesDirBaseName = "rcfiles"
|
||||
const MShellVersion = "v0.7.0"
|
||||
const WaveshellVersion = "v0.7.0"
|
||||
const RemoteIdFile = "remoteid"
|
||||
const DefaultMShellInstallBinDir = "/opt/mshell/bin"
|
||||
const DefaultWaveshellInstallBinDir = "/opt/mshell/bin"
|
||||
const LogFileName = "mshell.log"
|
||||
const ForceDebugLog = false
|
||||
|
||||
@ -90,7 +90,7 @@ func Logf(fmtStr string, args ...interface{}) {
|
||||
}
|
||||
|
||||
func InitDebugLog(prefix string) {
|
||||
homeDir := GetMShellHomeDir()
|
||||
homeDir := GetWaveshellHomeDir()
|
||||
err := os.MkdirAll(homeDir, 0777)
|
||||
if err != nil {
|
||||
return
|
||||
@ -163,7 +163,7 @@ func (ckey CommandKey) Validate(typeStr string) error {
|
||||
}
|
||||
|
||||
func HasDebugFlag(envMap map[string]string, flagName string) bool {
|
||||
msDebug := envMap[MShellDebugVarName]
|
||||
msDebug := envMap[WaveshellDebugVarName]
|
||||
flags := strings.Split(msDebug, ",")
|
||||
for _, flag := range flags {
|
||||
if strings.TrimSpace(flag) == flagName {
|
||||
@ -174,13 +174,13 @@ func HasDebugFlag(envMap map[string]string, flagName string) bool {
|
||||
}
|
||||
|
||||
func GetDebugRcFileName() string {
|
||||
msHome := GetMShellHomeDir()
|
||||
return path.Join(msHome, DebugRcFileName)
|
||||
wsHome := GetWaveshellHomeDir()
|
||||
return path.Join(wsHome, DebugRcFileName)
|
||||
}
|
||||
|
||||
func GetDebugReturnStateFileName() string {
|
||||
msHome := GetMShellHomeDir()
|
||||
return path.Join(msHome, DebugReturnStateFileName)
|
||||
wsHome := GetWaveshellHomeDir()
|
||||
return path.Join(wsHome, DebugReturnStateFileName)
|
||||
}
|
||||
|
||||
func GetHomeDir() string {
|
||||
@ -191,16 +191,16 @@ func GetHomeDir() string {
|
||||
return homeVar
|
||||
}
|
||||
|
||||
func GetMShellHomeDir() string {
|
||||
homeVar := os.Getenv(MShellHomeVarName)
|
||||
func GetWaveshellHomeDir() string {
|
||||
homeVar := os.Getenv(WaveshellHomeVarName)
|
||||
if homeVar != "" {
|
||||
return homeVar
|
||||
}
|
||||
return ExpandHomeDir(DefaultMShellHome)
|
||||
return ExpandHomeDir(DefaultWaveshellHome)
|
||||
}
|
||||
|
||||
func EnsureRcFilesDir() (string, error) {
|
||||
mhome := GetMShellHomeDir()
|
||||
mhome := GetWaveshellHomeDir()
|
||||
dirName := path.Join(mhome, RcFilesDirBaseName)
|
||||
err := CacheEnsureDir(dirName, RcFilesDirBaseName, 0700, "rcfiles dir")
|
||||
if err != nil {
|
||||
@ -209,18 +209,18 @@ func EnsureRcFilesDir() (string, error) {
|
||||
return dirName, nil
|
||||
}
|
||||
|
||||
func GetMShellPath() (string, error) {
|
||||
msPath := os.Getenv(MShellPathVarName) // use MSHELL_PATH
|
||||
if msPath != "" {
|
||||
return exec.LookPath(msPath)
|
||||
func GetWaveshellPath() (string, error) {
|
||||
wsPath := os.Getenv(WaveshellPathVarName) // use MSHELL_PATH -- will require rename
|
||||
if wsPath != "" {
|
||||
return exec.LookPath(wsPath)
|
||||
}
|
||||
mhome := GetMShellHomeDir()
|
||||
userMShellPath := path.Join(mhome, DefaultMShellName) // look in ~/.mshell
|
||||
msPath, err := exec.LookPath(userMShellPath)
|
||||
mhome := GetWaveshellHomeDir()
|
||||
userWaveshellPath := path.Join(mhome, DefaultWaveshellName) // look in ~/.mshell -- will require rename
|
||||
wsPath, err := exec.LookPath(userWaveshellPath)
|
||||
if err == nil {
|
||||
return msPath, nil
|
||||
return wsPath, nil
|
||||
}
|
||||
return exec.LookPath(DefaultMShellName) // standard path lookup for 'mshell'
|
||||
return exec.LookPath(DefaultWaveshellName) // standard path lookup for 'mshell'-- will require rename
|
||||
}
|
||||
|
||||
func ExpandHomeDir(pathStr string) string {
|
||||
@ -239,9 +239,9 @@ func ValidGoArch(goos string, goarch string) bool {
|
||||
}
|
||||
|
||||
func GoArchOptFile(version string, goos string, goarch string) string {
|
||||
installBinDir := os.Getenv(MShellInstallBinVarName)
|
||||
installBinDir := os.Getenv(WaveshellInstallBinVarName)
|
||||
if installBinDir == "" {
|
||||
installBinDir = DefaultMShellInstallBinDir
|
||||
installBinDir = DefaultWaveshellInstallBinDir
|
||||
}
|
||||
versionStr := semver.MajorMinor(version)
|
||||
if versionStr == "" {
|
||||
@ -252,22 +252,22 @@ func GoArchOptFile(version string, goos string, goarch string) string {
|
||||
}
|
||||
|
||||
func GetRemoteId() (string, error) {
|
||||
mhome := GetMShellHomeDir()
|
||||
homeInfo, err := os.Stat(mhome)
|
||||
wsHome := GetWaveshellHomeDir()
|
||||
homeInfo, err := os.Stat(wsHome)
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
err = os.MkdirAll(mhome, 0777)
|
||||
err = os.MkdirAll(wsHome, 0777)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot make mshell home directory[%s]: %w", mhome, err)
|
||||
return "", fmt.Errorf("cannot make waveshell home directory[%s]: %w", wsHome, err)
|
||||
}
|
||||
homeInfo, err = os.Stat(mhome)
|
||||
homeInfo, err = os.Stat(wsHome)
|
||||
}
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot stat mshell home directory[%s]: %w", mhome, err)
|
||||
return "", fmt.Errorf("cannot stat waveshell home directory[%s]: %w", wsHome, err)
|
||||
}
|
||||
if !homeInfo.IsDir() {
|
||||
return "", fmt.Errorf("mshell home directory[%s] is not a directory", mhome)
|
||||
return "", fmt.Errorf("waveshell home directory[%s] is not a directory", wsHome)
|
||||
}
|
||||
remoteIdFile := path.Join(mhome, RemoteIdFile)
|
||||
remoteIdFile := path.Join(wsHome, RemoteIdFile)
|
||||
fd, err := os.Open(remoteIdFile)
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
// write the file
|
||||
|
@ -687,18 +687,18 @@ func FmtMessagePacket(fmtStr string, args ...interface{}) *MessagePacketType {
|
||||
}
|
||||
|
||||
type InitPacketType struct {
|
||||
Type string `json:"type"`
|
||||
RespId string `json:"respid,omitempty"`
|
||||
Version string `json:"version"`
|
||||
BuildTime string `json:"buildtime,omitempty"`
|
||||
MShellHomeDir string `json:"mshellhomedir,omitempty"`
|
||||
HomeDir string `json:"homedir,omitempty"`
|
||||
User string `json:"user,omitempty"`
|
||||
HostName string `json:"hostname,omitempty"`
|
||||
NotFound bool `json:"notfound,omitempty"`
|
||||
UName string `json:"uname,omitempty"`
|
||||
Shell string `json:"shell,omitempty"`
|
||||
RemoteId string `json:"remoteid,omitempty"`
|
||||
Type string `json:"type"`
|
||||
RespId string `json:"respid,omitempty"`
|
||||
Version string `json:"version"`
|
||||
BuildTime string `json:"buildtime,omitempty"`
|
||||
WaveshellHomeDir string `json:"waveshellhomedir,omitempty"`
|
||||
HomeDir string `json:"homedir,omitempty"`
|
||||
User string `json:"user,omitempty"`
|
||||
HostName string `json:"hostname,omitempty"`
|
||||
NotFound bool `json:"notfound,omitempty"`
|
||||
UName string `json:"uname,omitempty"`
|
||||
Shell string `json:"shell,omitempty"`
|
||||
RemoteId string `json:"remoteid,omitempty"`
|
||||
}
|
||||
|
||||
func (*InitPacketType) GetType() string {
|
||||
@ -772,12 +772,12 @@ func MakeCmdDonePacket(ck base.CommandKey) *CmdDonePacketType {
|
||||
}
|
||||
|
||||
type CmdStartPacketType struct {
|
||||
Type string `json:"type"`
|
||||
RespId string `json:"respid,omitempty"`
|
||||
Ts int64 `json:"ts"`
|
||||
CK base.CommandKey `json:"ck"`
|
||||
Pid int `json:"pid,omitempty"`
|
||||
MShellPid int `json:"mshellpid,omitempty"`
|
||||
Type string `json:"type"`
|
||||
RespId string `json:"respid,omitempty"`
|
||||
Ts int64 `json:"ts"`
|
||||
CK base.CommandKey `json:"ck"`
|
||||
Pid int `json:"pid,omitempty"`
|
||||
WaveshellPid int `json:"waveshellpid,omitempty"`
|
||||
}
|
||||
|
||||
func (*CmdStartPacketType) GetType() string {
|
||||
|
@ -455,7 +455,7 @@ func (m *MServer) writeFile(pk *packet.WriteFilePacketType, wfc *WriteFileContex
|
||||
}
|
||||
var writeFd *os.File
|
||||
if pk.UseTemp {
|
||||
writeFd, err = os.CreateTemp("", "mshell.writefile.*") // "" means make this file in standard TempDir
|
||||
writeFd, err = os.CreateTemp("", "waveshell.writefile.*") // "" means make this file in standard TempDir
|
||||
if err != nil {
|
||||
resp := packet.MakeWriteFileReadyPacket(pk.ReqId)
|
||||
resp.Error = fmt.Sprintf("cannot create temp file: %v", err)
|
||||
@ -754,14 +754,14 @@ func (m *MServer) runCommand(runPacket *packet.RunPacketType) {
|
||||
m.Sender.SendErrorResponse(runPacket.ReqId, fmt.Errorf("test error"))
|
||||
return
|
||||
}
|
||||
ecmd, err := shexec.MakeMShellSingleCmd()
|
||||
ecmd, err := shexec.MakeWaveshellSingleCmd()
|
||||
if err != nil {
|
||||
m.Sender.SendErrorResponse(runPacket.ReqId, fmt.Errorf("server run packets require valid ck: %s", err))
|
||||
return
|
||||
}
|
||||
cproc, err := shexec.MakeClientProc(context.Background(), shexec.CmdWrap{Cmd: ecmd})
|
||||
if err != nil {
|
||||
m.Sender.SendErrorResponse(runPacket.ReqId, fmt.Errorf("starting mshell client: %s", err))
|
||||
m.Sender.SendErrorResponse(runPacket.ReqId, fmt.Errorf("starting waveshell client: %s", err))
|
||||
return
|
||||
}
|
||||
m.Lock.Lock()
|
||||
@ -833,7 +833,7 @@ func (server *MServer) runReadLoop() {
|
||||
}
|
||||
continue
|
||||
}
|
||||
server.Sender.SendMessageFmt("invalid packet '%s' sent to mshell server", packet.AsString(pk))
|
||||
server.Sender.SendMessageFmt("invalid packet '%s' sent to waveshell server", packet.AsString(pk))
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ const FirstExtraFilesFdNum = 3
|
||||
func StreamCommandWithExtraFd(ctx context.Context, ecmd *exec.Cmd, outputCh chan []byte, extraFdNum int, endBytes []byte, stdinDataCh chan []byte) ([]byte, error) {
|
||||
defer close(outputCh)
|
||||
ecmd.Env = os.Environ()
|
||||
shellutil.UpdateCmdEnv(ecmd, shellutil.MShellEnvVars(shellutil.DefaultTermType))
|
||||
shellutil.UpdateCmdEnv(ecmd, shellutil.WaveshellEnvVars(shellutil.DefaultTermType))
|
||||
cmdPty, cmdTty, err := pty.Open()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("opening new pty: %w", err)
|
||||
@ -232,7 +232,7 @@ func StreamCommandWithExtraFd(ctx context.Context, ecmd *exec.Cmd, outputCh chan
|
||||
|
||||
func RunSimpleCmdInPty(ecmd *exec.Cmd, endBytes []byte) ([]byte, error) {
|
||||
ecmd.Env = os.Environ()
|
||||
shellutil.UpdateCmdEnv(ecmd, shellutil.MShellEnvVars(shellutil.DefaultTermType))
|
||||
shellutil.UpdateCmdEnv(ecmd, shellutil.WaveshellEnvVars(shellutil.DefaultTermType))
|
||||
cmdPty, cmdTty, err := pty.Open()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("opening new pty: %w", err)
|
||||
@ -311,8 +311,8 @@ func parseExtVarOutput(pvarBytes []byte, promptOutput string, zmodsOutput string
|
||||
|
||||
// for debugging (not for production use)
|
||||
func writeStateToFile(shellType string, outputBytes []byte) error {
|
||||
msHome := base.GetMShellHomeDir()
|
||||
stateFileName := path.Join(msHome, shellType+"-state.txt")
|
||||
wsHome := base.GetWaveshellHomeDir()
|
||||
stateFileName := path.Join(wsHome, shellType+"-state.txt")
|
||||
os.WriteFile(stateFileName, outputBytes, 0644)
|
||||
return nil
|
||||
}
|
||||
|
@ -15,13 +15,13 @@ const DefaultTermType = "xterm-256color"
|
||||
const DefaultTermRows = 24
|
||||
const DefaultTermCols = 80
|
||||
|
||||
func MShellEnvVars(termType string) map[string]string {
|
||||
func WaveshellEnvVars(termType string) map[string]string {
|
||||
rtn := make(map[string]string)
|
||||
if termType != "" {
|
||||
rtn["TERM"] = termType
|
||||
}
|
||||
rtn["WAVESHELL"], _ = os.Executable()
|
||||
rtn["WAVESHELL_VERSION"] = base.MShellVersion
|
||||
rtn["WAVESHELL_VERSION"] = base.WaveshellVersion
|
||||
return rtn
|
||||
}
|
||||
|
||||
|
@ -170,8 +170,8 @@ type WaveshellLaunchError struct {
|
||||
func (wle WaveshellLaunchError) Error() string {
|
||||
if wle.InitPk.NotFound {
|
||||
return "waveshell client not found"
|
||||
} else if semver.MajorMinor(wle.InitPk.Version) != semver.MajorMinor(base.MShellVersion) {
|
||||
return fmt.Sprintf("invalid remote waveshell version '%s', must be '=%s'", wle.InitPk.Version, semver.MajorMinor(base.MShellVersion))
|
||||
} else if semver.MajorMinor(wle.InitPk.Version) != semver.MajorMinor(base.WaveshellVersion) {
|
||||
return fmt.Sprintf("invalid remote waveshell version '%s', must be '=%s'", wle.InitPk.Version, semver.MajorMinor(base.WaveshellVersion))
|
||||
}
|
||||
return fmt.Sprintf("invalid waveshell: init packet=%v", *wle.InitPk)
|
||||
}
|
||||
@ -232,7 +232,7 @@ func MakeClientProc(ctx context.Context, ecmd ConnInterface) (*ClientProc, error
|
||||
cproc.Close()
|
||||
return nil, WaveshellLaunchError{InitPk: initPk}
|
||||
}
|
||||
if semver.MajorMinor(initPk.Version) != semver.MajorMinor(base.MShellVersion) {
|
||||
if semver.MajorMinor(initPk.Version) != semver.MajorMinor(base.WaveshellVersion) {
|
||||
cproc.Close()
|
||||
return nil, WaveshellLaunchError{InitPk: initPk}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ fi
|
||||
`
|
||||
|
||||
func MakeClientCommandStr() string {
|
||||
return strings.ReplaceAll(ClientCommandFmt, "[%VERSION%]", semver.MajorMinor(base.MShellVersion))
|
||||
return strings.ReplaceAll(ClientCommandFmt, "[%VERSION%]", semver.MajorMinor(base.WaveshellVersion))
|
||||
}
|
||||
|
||||
const InstallCommandFmt = `
|
||||
@ -88,10 +88,10 @@ fi
|
||||
`
|
||||
|
||||
func MakeInstallCommandStr() string {
|
||||
return strings.ReplaceAll(InstallCommandFmt, "[%VERSION%]", semver.MajorMinor(base.MShellVersion))
|
||||
return strings.ReplaceAll(InstallCommandFmt, "[%VERSION%]", semver.MajorMinor(base.WaveshellVersion))
|
||||
}
|
||||
|
||||
type MShellBinaryReaderFn func(version string, goos string, goarch string) (io.ReadCloser, error)
|
||||
type WaveshellBinaryReaderFn func(version string, goos string, goarch string) (io.ReadCloser, error)
|
||||
|
||||
type ReturnStateBuf struct {
|
||||
Lock *sync.Mutex
|
||||
@ -277,7 +277,7 @@ func (c *ShExecType) MakeCmdStartPacket(reqId string) *packet.CmdStartPacketType
|
||||
startPacket.Ts = time.Now().UnixMilli()
|
||||
startPacket.CK = c.CK
|
||||
startPacket.Pid = c.Cmd.Process.Pid
|
||||
startPacket.MShellPid = os.Getpid()
|
||||
startPacket.WaveshellPid = os.Getpid()
|
||||
return startPacket
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ func MakeSimpleStaticWriterPipe(data []byte) (*os.File, error) {
|
||||
}
|
||||
|
||||
func MakeRunnerExec(ck base.CommandKey) (*exec.Cmd, error) {
|
||||
msPath, err := base.GetMShellPath()
|
||||
msPath, err := base.GetWaveshellPath()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -317,7 +317,7 @@ func MakeDetachedExecCmd(pk *packet.RunPacketType, cmdTty *os.File) (*exec.Cmd,
|
||||
ecmd.Env = os.Environ()
|
||||
}
|
||||
shellutil.UpdateCmdEnv(ecmd, shellenv.EnvMapFromState(state))
|
||||
shellutil.UpdateCmdEnv(ecmd, shellutil.MShellEnvVars(getTermType(pk)))
|
||||
shellutil.UpdateCmdEnv(ecmd, shellutil.WaveshellEnvVars(getTermType(pk)))
|
||||
if state.Cwd != "" {
|
||||
ecmd.Dir = base.ExpandHomeDir(state.Cwd)
|
||||
}
|
||||
@ -470,10 +470,10 @@ type ClientOpts struct {
|
||||
UsePty bool
|
||||
}
|
||||
|
||||
func MakeMShellSingleCmd() (*exec.Cmd, error) {
|
||||
func MakeWaveshellSingleCmd() (*exec.Cmd, error) {
|
||||
execFile, err := os.Executable()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot find local mshell executable: %w", err)
|
||||
return nil, fmt.Errorf("cannot find local waveshell executable: %w", err)
|
||||
}
|
||||
ecmd := exec.Command(execFile, "--single-from-server")
|
||||
return ecmd, nil
|
||||
@ -528,31 +528,6 @@ func (opts SSHOpts) MakeSSHExecCmd(remoteCommand string, sapi shellapi.ShellApi)
|
||||
}
|
||||
}
|
||||
|
||||
func (opts SSHOpts) MakeMShellSSHOpts() string {
|
||||
var moreSSHOpts []string
|
||||
if opts.SSHIdentity != "" {
|
||||
identityOpt := fmt.Sprintf("-i %s", shellescape.Quote(opts.SSHIdentity))
|
||||
moreSSHOpts = append(moreSSHOpts, identityOpt)
|
||||
}
|
||||
if opts.SSHUser != "" {
|
||||
userOpt := fmt.Sprintf("-l %s", shellescape.Quote(opts.SSHUser))
|
||||
moreSSHOpts = append(moreSSHOpts, userOpt)
|
||||
}
|
||||
if opts.SSHPort != 0 {
|
||||
portOpt := fmt.Sprintf("-p %d", opts.SSHPort)
|
||||
moreSSHOpts = append(moreSSHOpts, portOpt)
|
||||
}
|
||||
if opts.SSHOptsStr != "" {
|
||||
optsOpt := fmt.Sprintf("--ssh-opts %s", shellescape.Quote(opts.SSHOptsStr))
|
||||
moreSSHOpts = append(moreSSHOpts, optsOpt)
|
||||
}
|
||||
if opts.SSHHost != "" {
|
||||
sshArg := fmt.Sprintf("--ssh %s", shellescape.Quote(opts.SSHHost))
|
||||
moreSSHOpts = append(moreSSHOpts, sshArg)
|
||||
}
|
||||
return strings.Join(moreSSHOpts, " ")
|
||||
}
|
||||
|
||||
func GetTerminalSize() (int, int, error) {
|
||||
fd, err := os.Open("/dev/tty")
|
||||
if err != nil {
|
||||
@ -610,19 +585,19 @@ func ValidateRemoteFds(rfds []packet.RemoteFd) error {
|
||||
dupMap := make(map[int]bool)
|
||||
for _, rfd := range rfds {
|
||||
if rfd.FdNum < 0 {
|
||||
return fmt.Errorf("mshell negative fd numbers fd=%d", rfd.FdNum)
|
||||
return fmt.Errorf("waveshell negative fd numbers fd=%d", rfd.FdNum)
|
||||
}
|
||||
if rfd.FdNum < FirstExtraFilesFdNum {
|
||||
return fmt.Errorf("mshell does not support re-opening fd=%d (0, 1, and 2, are always open)", rfd.FdNum)
|
||||
return fmt.Errorf("waveshell does not support re-opening fd=%d (0, 1, and 2, are always open)", rfd.FdNum)
|
||||
}
|
||||
if rfd.FdNum > MaxFdNum {
|
||||
return fmt.Errorf("mshell does not support opening fd numbers above %d", MaxFdNum)
|
||||
return fmt.Errorf("waveshell does not support opening fd numbers above %d", MaxFdNum)
|
||||
}
|
||||
if dupMap[rfd.FdNum] {
|
||||
return fmt.Errorf("mshell got duplicate entries for fd=%d", rfd.FdNum)
|
||||
return fmt.Errorf("waveshell got duplicate entries for fd=%d", rfd.FdNum)
|
||||
}
|
||||
if rfd.Read && rfd.Write {
|
||||
return fmt.Errorf("mshell does not support opening fd numbers for reading and writing, fd=%d", rfd.FdNum)
|
||||
return fmt.Errorf("waveshell does not support opening fd numbers for reading and writing, fd=%d", rfd.FdNum)
|
||||
}
|
||||
if !rfd.Read && !rfd.Write {
|
||||
return fmt.Errorf("invalid fd=%d, neither reading or writing mode specified", rfd.FdNum)
|
||||
@ -632,14 +607,14 @@ func ValidateRemoteFds(rfds []packet.RemoteFd) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func sendMShellBinary(input io.WriteCloser, mshellStream io.Reader) {
|
||||
func sendWaveshellBinary(input io.WriteCloser, waveshellStream io.Reader) {
|
||||
go func() {
|
||||
defer input.Close()
|
||||
io.Copy(input, mshellStream)
|
||||
io.Copy(input, waveshellStream)
|
||||
}()
|
||||
}
|
||||
|
||||
func RunInstallFromCmd(ctx context.Context, ecmd ConnInterface, tryDetect bool, mshellStream io.Reader, mshellReaderFn MShellBinaryReaderFn, msgFn func(string)) error {
|
||||
func RunInstallFromCmd(ctx context.Context, ecmd ConnInterface, tryDetect bool, waveshellStream io.Reader, waveshellReaderFn WaveshellBinaryReaderFn, msgFn func(string)) error {
|
||||
inputWriter, err := ecmd.StdinPipe()
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating stdin pipe: %v", err)
|
||||
@ -655,8 +630,8 @@ func RunInstallFromCmd(ctx context.Context, ecmd ConnInterface, tryDetect bool,
|
||||
go func() {
|
||||
io.Copy(os.Stderr, stderrReader)
|
||||
}()
|
||||
if mshellStream != nil {
|
||||
sendMShellBinary(inputWriter, mshellStream)
|
||||
if waveshellStream != nil {
|
||||
sendWaveshellBinary(inputWriter, waveshellStream)
|
||||
}
|
||||
packetParser := packet.MakePacketParser(stdoutReader, nil)
|
||||
err = ecmd.Start()
|
||||
@ -686,24 +661,24 @@ func RunInstallFromCmd(ctx context.Context, ecmd ConnInterface, tryDetect bool,
|
||||
}
|
||||
goos, goarch, err := DetectGoArch(initPacket.UName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("arch cannot be detected (might be incompatible with mshell): %w", err)
|
||||
return fmt.Errorf("arch cannot be detected (might be incompatible with waveshell): %w", err)
|
||||
}
|
||||
msgStr := fmt.Sprintf("mshell detected remote architecture as '%s.%s'\n", goos, goarch)
|
||||
msgStr := fmt.Sprintf("waveshell detected remote architecture as '%s.%s'\n", goos, goarch)
|
||||
msgFn(msgStr)
|
||||
detectedMSS, err := mshellReaderFn(base.MShellVersion, goos, goarch)
|
||||
detectedMSS, err := waveshellReaderFn(base.WaveshellVersion, goos, goarch)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer detectedMSS.Close()
|
||||
sendMShellBinary(inputWriter, detectedMSS)
|
||||
sendWaveshellBinary(inputWriter, detectedMSS)
|
||||
continue
|
||||
}
|
||||
if pk.GetType() == packet.InitPacketStr && !firstInit {
|
||||
initPacket := pk.(*packet.InitPacketType)
|
||||
if initPacket.Version == base.MShellVersion {
|
||||
if initPacket.Version == base.WaveshellVersion {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("invalid version '%s' received from client, expecting '%s'", initPacket.Version, base.MShellVersion)
|
||||
return fmt.Errorf("invalid version '%s' received from client, expecting '%s'", initPacket.Version, base.WaveshellVersion)
|
||||
}
|
||||
if pk.GetType() == packet.RawPacketStr {
|
||||
rawPk := pk.(*packet.RawPacketType)
|
||||
@ -770,7 +745,7 @@ func DetectGoArch(uname string) (string, string, error) {
|
||||
osVal := strings.TrimSpace(strings.ToLower(fields[0]))
|
||||
archVal := strings.TrimSpace(strings.ToLower(fields[1]))
|
||||
if osVal != "darwin" && osVal != "linux" {
|
||||
return "", "", fmt.Errorf("invalid uname OS '%s', mshell only supports OS X (darwin) and linux", osVal)
|
||||
return "", "", fmt.Errorf("invalid uname OS '%s', waveshell only supports OS X (darwin) and linux", osVal)
|
||||
}
|
||||
goos := osVal
|
||||
goarch := ""
|
||||
@ -780,7 +755,7 @@ func DetectGoArch(uname string) (string, string, error) {
|
||||
goarch = "arm64"
|
||||
}
|
||||
if goarch == "" {
|
||||
return "", "", fmt.Errorf("invalid uname machine type '%s', mshell only supports aarch64 (amd64) and x86_64 (amd64)", archVal)
|
||||
return "", "", fmt.Errorf("invalid uname machine type '%s', waveshell only supports aarch64 (amd64) and x86_64 (amd64)", archVal)
|
||||
}
|
||||
if !base.ValidGoArch(goos, goarch) {
|
||||
return "", "", fmt.Errorf("invalid arch detected %s.%s", goos, goarch)
|
||||
@ -975,7 +950,7 @@ func RunCommandSimple(pk *packet.RunPacketType, sender *packet.PacketSender, fro
|
||||
cmdTty.Close()
|
||||
}()
|
||||
cmd.CmdPty = cmdPty
|
||||
shellutil.UpdateCmdEnv(cmd.Cmd, shellutil.MShellEnvVars(getTermType(pk)))
|
||||
shellutil.UpdateCmdEnv(cmd.Cmd, shellutil.WaveshellEnvVars(getTermType(pk)))
|
||||
}
|
||||
if cmdTty != nil {
|
||||
cmd.Cmd.Stdin = cmdTty
|
||||
@ -1151,8 +1126,8 @@ func (rs *ReturnStateBuf) Run() {
|
||||
}
|
||||
}
|
||||
|
||||
// in detached run mode, we don't want mshell to die from signals
|
||||
// since we want mshell to persist even if the mshell --server is terminated
|
||||
// in detached run mode, we don't want waveshell to die from signals since
|
||||
// we want waveshell to persist even if the waveshell --server is terminated
|
||||
func SetupSignalsForDetach() {
|
||||
sigCh := make(chan os.Signal, 1)
|
||||
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGPIPE)
|
||||
@ -1163,8 +1138,8 @@ func SetupSignalsForDetach() {
|
||||
}()
|
||||
}
|
||||
|
||||
// in detached run mode, we don't want mshell to die from signals
|
||||
// since we want mshell to persist even if the mshell --server is terminated
|
||||
// in detached run mode, we don't want waveshell to die from signals since
|
||||
// we want waveshell to persist even if the waveshell --server is terminated
|
||||
func IgnoreSigPipe() {
|
||||
sigCh := make(chan os.Signal, 1)
|
||||
signal.Notify(sigCh, syscall.SIGPIPE)
|
||||
@ -1241,10 +1216,10 @@ func (c *ShExecType) WaitForCommand() *packet.CmdDonePacketType {
|
||||
|
||||
func MakeInitPacket() *packet.InitPacketType {
|
||||
initPacket := packet.MakeInitPacket()
|
||||
initPacket.Version = base.MShellVersion
|
||||
initPacket.Version = base.WaveshellVersion
|
||||
initPacket.BuildTime = base.BuildTime
|
||||
initPacket.HomeDir = base.GetHomeDir()
|
||||
initPacket.MShellHomeDir = base.GetMShellHomeDir()
|
||||
initPacket.WaveshellHomeDir = base.GetWaveshellHomeDir()
|
||||
if user, _ := user.Current(); user != nil {
|
||||
initPacket.User = user.Username
|
||||
}
|
||||
|
@ -452,12 +452,12 @@ func HandleWriteFile(w http.ResponseWriter, r *http.Request) {
|
||||
WriteJsonError(w, fmt.Errorf("invalid line, no remote"))
|
||||
return
|
||||
}
|
||||
msh := remote.GetRemoteById(cmd.Remote.RemoteId)
|
||||
if msh == nil {
|
||||
wsh := remote.GetRemoteById(cmd.Remote.RemoteId)
|
||||
if wsh == nil {
|
||||
WriteJsonError(w, fmt.Errorf("invalid line, cannot resolve remote"))
|
||||
return
|
||||
}
|
||||
rrState := msh.GetRemoteRuntimeState()
|
||||
rrState := wsh.GetRemoteRuntimeState()
|
||||
fullPath, err := rrState.ExpandHomeDir(params.Path)
|
||||
if err != nil {
|
||||
WriteJsonError(w, fmt.Errorf("error expanding homedir: %v", err))
|
||||
@ -472,7 +472,7 @@ func HandleWriteFile(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
writePk.Path = filepath.Join(cwd, fullPath)
|
||||
}
|
||||
iter, err := msh.PacketRpcIter(r.Context(), writePk)
|
||||
iter, err := wsh.PacketRpcIter(r.Context(), writePk)
|
||||
if err != nil {
|
||||
WriteJsonError(w, fmt.Errorf("error: %v", err))
|
||||
return
|
||||
@ -502,7 +502,7 @@ func HandleWriteFile(w http.ResponseWriter, r *http.Request) {
|
||||
} else if err != nil {
|
||||
dataErr := fmt.Errorf("error reading file data: %v", err)
|
||||
dataPk.Error = dataErr.Error()
|
||||
msh.SendFileData(dataPk)
|
||||
wsh.SendFileData(dataPk)
|
||||
WriteJsonError(w, dataErr)
|
||||
return
|
||||
}
|
||||
@ -510,7 +510,7 @@ func HandleWriteFile(w http.ResponseWriter, r *http.Request) {
|
||||
dataPk.Data = make([]byte, nr)
|
||||
copy(dataPk.Data, bufSlice[0:nr])
|
||||
}
|
||||
msh.SendFileData(dataPk)
|
||||
wsh.SendFileData(dataPk)
|
||||
if dataPk.Eof {
|
||||
break
|
||||
}
|
||||
@ -581,13 +581,13 @@ func HandleReadFile(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("invalid line, no remote"))
|
||||
return
|
||||
}
|
||||
msh := remote.GetRemoteById(cmd.Remote.RemoteId)
|
||||
if msh == nil {
|
||||
wsh := remote.GetRemoteById(cmd.Remote.RemoteId)
|
||||
if wsh == nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte("invalid line, cannot resolve remote"))
|
||||
return
|
||||
}
|
||||
rrState := msh.GetRemoteRuntimeState()
|
||||
rrState := wsh.GetRemoteRuntimeState()
|
||||
fullPath, err := rrState.ExpandHomeDir(path)
|
||||
if err != nil {
|
||||
WriteJsonError(w, fmt.Errorf("error expanding homedir: %v", err))
|
||||
@ -601,7 +601,7 @@ func HandleReadFile(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
streamPk.Path = filepath.Join(cwd, fullPath)
|
||||
}
|
||||
iter, err := msh.StreamFile(r.Context(), streamPk)
|
||||
iter, err := wsh.StreamFile(r.Context(), streamPk)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(fmt.Sprintf("error trying to stream file: %v", err)))
|
||||
|
@ -1311,7 +1311,7 @@ func checkForWriteFinished(ctx context.Context, iter *packet.RpcResponseIter) er
|
||||
return nil
|
||||
}
|
||||
|
||||
func doCopyLocalFileToRemote(ctx context.Context, cmd *sstore.CmdType, remote_msh *remote.MShellProc, localPath string, destPath string, outputPos int64) {
|
||||
func doCopyLocalFileToRemote(ctx context.Context, cmd *sstore.CmdType, remoteWsh *remote.WaveshellProc, localPath string, destPath string, outputPos int64) {
|
||||
var exitSuccess bool
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
@ -1326,7 +1326,7 @@ func doCopyLocalFileToRemote(ctx context.Context, cmd *sstore.CmdType, remote_ms
|
||||
writePk := packet.MakeWriteFilePacket()
|
||||
writePk.ReqId = uuid.New().String()
|
||||
writePk.Path = destPath
|
||||
iter, err := remote_msh.WriteFile(ctx, writePk)
|
||||
iter, err := remoteWsh.WriteFile(ctx, writePk)
|
||||
if err != nil {
|
||||
writeStringToPty(ctx, cmd, fmt.Sprintf("Error starting file write: %v\r\n", err), &outputPos)
|
||||
return
|
||||
@ -1358,7 +1358,7 @@ func doCopyLocalFileToRemote(ctx context.Context, cmd *sstore.CmdType, remote_ms
|
||||
} else if err != nil {
|
||||
dataErr := fmt.Sprintf("error reading file data: %v", err)
|
||||
dataPk.Error = dataErr
|
||||
remote_msh.SendFileData(dataPk)
|
||||
remoteWsh.SendFileData(dataPk)
|
||||
writeStringToPty(ctx, cmd, dataErr, &outputPos)
|
||||
return
|
||||
}
|
||||
@ -1373,7 +1373,7 @@ func doCopyLocalFileToRemote(ctx context.Context, cmd *sstore.CmdType, remote_ms
|
||||
lastFileTransferPercentage = fileTransferPercentage
|
||||
}
|
||||
}
|
||||
remote_msh.SendFileData(dataPk)
|
||||
remoteWsh.SendFileData(dataPk)
|
||||
if dataPk.Eof {
|
||||
break
|
||||
}
|
||||
@ -1405,7 +1405,7 @@ func getStatusBarString(filePercentageInt int) string {
|
||||
return statusBarString
|
||||
}
|
||||
|
||||
func doCopyRemoteFileToRemote(ctx context.Context, cmd *sstore.CmdType, sourceMsh *remote.MShellProc, destMsh *remote.MShellProc, sourcePath string, destPath string, outputPos int64) {
|
||||
func doCopyRemoteFileToRemote(ctx context.Context, cmd *sstore.CmdType, sourceWsh *remote.WaveshellProc, destWsh *remote.WaveshellProc, sourcePath string, destPath string, outputPos int64) {
|
||||
var exitSuccess bool
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
@ -1414,7 +1414,7 @@ func doCopyRemoteFileToRemote(ctx context.Context, cmd *sstore.CmdType, sourceMs
|
||||
streamPk := packet.MakeStreamFilePacket()
|
||||
streamPk.ReqId = uuid.New().String()
|
||||
streamPk.Path = sourcePath
|
||||
sourceStreamIter, err := sourceMsh.StreamFile(ctx, streamPk)
|
||||
sourceStreamIter, err := sourceWsh.StreamFile(ctx, streamPk)
|
||||
if err != nil {
|
||||
writeStringToPty(ctx, cmd, fmt.Sprintf("Error getting file data packet: %v\r\n", err), &outputPos)
|
||||
return
|
||||
@ -1443,7 +1443,7 @@ func doCopyRemoteFileToRemote(ctx context.Context, cmd *sstore.CmdType, sourceMs
|
||||
writePk := packet.MakeWriteFilePacket()
|
||||
writePk.ReqId = uuid.New().String()
|
||||
writePk.Path = destPath
|
||||
destWriteIter, err := destMsh.WriteFile(ctx, writePk)
|
||||
destWriteIter, err := destWsh.WriteFile(ctx, writePk)
|
||||
if err != nil {
|
||||
writeStringToPty(ctx, cmd, fmt.Sprintf("Error starting file write: %v\r\n", err), &outputPos)
|
||||
return
|
||||
@ -1482,7 +1482,7 @@ func doCopyRemoteFileToRemote(ctx context.Context, cmd *sstore.CmdType, sourceMs
|
||||
writeDataPk.Type = dataPk.Type
|
||||
writeDataPk.Data = make([]byte, int64(len(dataPk.Data)))
|
||||
copy(writeDataPk.Data, dataPk.Data)
|
||||
err = destMsh.SendFileData(writeDataPk)
|
||||
err = destWsh.SendFileData(writeDataPk)
|
||||
if err != nil {
|
||||
writeStringToPty(ctx, cmd, fmt.Sprintf("error sending file to dest: %v\r\n", err), &outputPos)
|
||||
return
|
||||
@ -1542,7 +1542,7 @@ func doCopyLocalFileToLocal(ctx context.Context, cmd *sstore.CmdType, sourcePath
|
||||
exitSuccess = true
|
||||
}
|
||||
|
||||
func doCopyRemoteFileToLocal(ctx context.Context, cmd *sstore.CmdType, remote_msh *remote.MShellProc, sourcePath string, localPath string, outputPos int64) {
|
||||
func doCopyRemoteFileToLocal(ctx context.Context, cmd *sstore.CmdType, remoteWsh *remote.WaveshellProc, sourcePath string, localPath string, outputPos int64) {
|
||||
var exitSuccess bool
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
@ -1551,7 +1551,7 @@ func doCopyRemoteFileToLocal(ctx context.Context, cmd *sstore.CmdType, remote_ms
|
||||
streamPk := packet.MakeStreamFilePacket()
|
||||
streamPk.ReqId = uuid.New().String()
|
||||
streamPk.Path = sourcePath
|
||||
iter, err := remote_msh.StreamFile(ctx, streamPk)
|
||||
iter, err := remoteWsh.StreamFile(ctx, streamPk)
|
||||
if err != nil {
|
||||
writeStringToPty(ctx, cmd, fmt.Sprintf("Error getting file data packet: %v\r\n", err), &outputPos)
|
||||
return
|
||||
@ -1700,11 +1700,11 @@ func CopyFileCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scb
|
||||
|
||||
var sourceFullPath string
|
||||
var destFullPath string
|
||||
sourceMsh := sourceRemoteId.MShell
|
||||
if sourceMsh == nil {
|
||||
return nil, fmt.Errorf("failure getting source remote mshell")
|
||||
sourceWsh := sourceRemoteId.Waveshell
|
||||
if sourceWsh == nil {
|
||||
return nil, fmt.Errorf("failure getting source remote waveshell")
|
||||
}
|
||||
sourceRRState := sourceMsh.GetRemoteRuntimeState()
|
||||
sourceRRState := sourceWsh.GetRemoteRuntimeState()
|
||||
sourcePathWithHome, err := sourceRRState.ExpandHomeDir(sourcePath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("expand home dir err: %v", err)
|
||||
@ -1720,11 +1720,11 @@ func CopyFileCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scb
|
||||
sourceFileName := filepath.Base(sourceFullPath)
|
||||
destPath = filepath.Join(destPath, sourceFileName)
|
||||
}
|
||||
destMsh := destRemoteId.MShell
|
||||
if destMsh == nil {
|
||||
return nil, fmt.Errorf("failure getting dest remote mshell")
|
||||
destWsh := destRemoteId.Waveshell
|
||||
if destWsh == nil {
|
||||
return nil, fmt.Errorf("failure getting dest remote waveshell")
|
||||
}
|
||||
destRRState := destMsh.GetRemoteRuntimeState()
|
||||
destRRState := destWsh.GetRemoteRuntimeState()
|
||||
destPathWithHome, err := destRRState.ExpandHomeDir(destPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("expand home dir err: %v", err)
|
||||
@ -1757,7 +1757,7 @@ func CopyFileCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scb
|
||||
update.AddUpdate(sstore.InteractiveUpdate(pk.Interactive))
|
||||
if destRemote != ConnectedRemote && destRemoteId != nil && !destRemoteId.RState.IsConnected() {
|
||||
writeStringToPty(ctx, cmd, fmt.Sprintf("Attempting to autoconnect to remote %v\r\n", destRemote), &outputPos)
|
||||
err = destRemoteId.MShell.TryAutoConnect()
|
||||
err = destRemoteId.Waveshell.TryAutoConnect()
|
||||
if err != nil {
|
||||
writeStringToPty(ctx, cmd, fmt.Sprintf("Couldn't connect to remote %v\r\n", sourceRemote), &outputPos)
|
||||
} else {
|
||||
@ -1766,7 +1766,7 @@ func CopyFileCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scb
|
||||
}
|
||||
if sourceRemote != LocalRemote && sourceRemoteId != nil && !sourceRemoteId.RState.IsConnected() {
|
||||
writeStringToPty(ctx, cmd, fmt.Sprintf("Attempting to autoconnect to remote %v\r\n", sourceRemote), &outputPos)
|
||||
err = sourceRemoteId.MShell.TryAutoConnect()
|
||||
err = sourceRemoteId.Waveshell.TryAutoConnect()
|
||||
if err != nil {
|
||||
writeStringToPty(ctx, cmd, fmt.Sprintf("Couldn't connect to remote %v\r\n", sourceRemote), &outputPos)
|
||||
} else {
|
||||
@ -1778,11 +1778,11 @@ func CopyFileCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scb
|
||||
if destRemote == LocalRemote && sourceRemote == LocalRemote {
|
||||
go doCopyLocalFileToLocal(context.Background(), cmd, sourceFullPath, destFullPath, outputPos)
|
||||
} else if destRemote == LocalRemote && sourceRemote != LocalRemote {
|
||||
go doCopyRemoteFileToLocal(context.Background(), cmd, sourceMsh, sourceFullPath, destFullPath, outputPos)
|
||||
go doCopyRemoteFileToLocal(context.Background(), cmd, sourceWsh, sourceFullPath, destFullPath, outputPos)
|
||||
} else if destRemote != LocalRemote && sourceRemote == LocalRemote {
|
||||
go doCopyLocalFileToRemote(context.Background(), cmd, destMsh, sourceFullPath, destFullPath, outputPos)
|
||||
go doCopyLocalFileToRemote(context.Background(), cmd, destWsh, sourceFullPath, destFullPath, outputPos)
|
||||
} else if destRemote != LocalRemote && sourceRemote != LocalRemote {
|
||||
go doCopyRemoteFileToRemote(context.Background(), cmd, sourceMsh, destMsh, sourceFullPath, destFullPath, outputPos)
|
||||
go doCopyRemoteFileToRemote(context.Background(), cmd, sourceWsh, destWsh, sourceFullPath, destFullPath, outputPos)
|
||||
}
|
||||
return update, nil
|
||||
}
|
||||
@ -1792,8 +1792,8 @@ func RemoteInstallCommand(ctx context.Context, pk *scpacket.FeCommandPacketType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mshell := ids.Remote.MShell
|
||||
go mshell.RunInstall(false)
|
||||
wshell := ids.Remote.Waveshell
|
||||
go wshell.RunInstall(false)
|
||||
return createRemoteViewRemoteIdUpdate(ids.Remote.RemotePtr.RemoteId), nil
|
||||
}
|
||||
|
||||
@ -1802,8 +1802,8 @@ func RemoteInstallCancelCommand(ctx context.Context, pk *scpacket.FeCommandPacke
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mshell := ids.Remote.MShell
|
||||
go mshell.CancelInstall()
|
||||
wshell := ids.Remote.Waveshell
|
||||
go wshell.CancelInstall()
|
||||
return createRemoteViewRemoteIdUpdate(ids.Remote.RemotePtr.RemoteId), nil
|
||||
}
|
||||
|
||||
@ -1812,7 +1812,7 @@ func RemoteConnectCommand(ctx context.Context, pk *scpacket.FeCommandPacketType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
go ids.Remote.MShell.Launch(true)
|
||||
go ids.Remote.Waveshell.Launch(true)
|
||||
return createRemoteViewRemoteIdUpdate(ids.Remote.RemotePtr.RemoteId), nil
|
||||
}
|
||||
|
||||
@ -1822,7 +1822,7 @@ func RemoteDisconnectCommand(ctx context.Context, pk *scpacket.FeCommandPacketTy
|
||||
return nil, err
|
||||
}
|
||||
force := resolveBool(pk.Kwargs["force"], false)
|
||||
go ids.Remote.MShell.Disconnect(force)
|
||||
go ids.Remote.Waveshell.Disconnect(force)
|
||||
return createRemoteViewRemoteIdUpdate(ids.Remote.RemotePtr.RemoteId), nil
|
||||
}
|
||||
|
||||
@ -2082,7 +2082,7 @@ func RemoteSetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sc
|
||||
}
|
||||
visualEdit := resolveBool(pk.Kwargs["visual"], false)
|
||||
isSubmitted := resolveBool(pk.Kwargs["submit"], false)
|
||||
editArgs, err := parseRemoteEditArgs(false, pk, ids.Remote.MShell.IsLocal())
|
||||
editArgs, err := parseRemoteEditArgs(false, pk, ids.Remote.Waveshell.IsLocal())
|
||||
if err != nil {
|
||||
return makeRemoteEditErrorReturn_edit(ids, visualEdit, fmt.Errorf("/remote:new %v", err))
|
||||
}
|
||||
@ -2092,7 +2092,7 @@ func RemoteSetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sc
|
||||
if !visualEdit && len(editArgs.EditMap) == 0 {
|
||||
return nil, fmt.Errorf("/remote:set no updates, can set %s. (set visual=1 to edit in UI)", formatStrs(RemoteSetArgs, "or", false))
|
||||
}
|
||||
err = ids.Remote.MShell.UpdateRemote(ctx, editArgs.EditMap)
|
||||
err = ids.Remote.Waveshell.UpdateRemote(ctx, editArgs.EditMap)
|
||||
if err != nil {
|
||||
return makeRemoteEditErrorReturn_edit(ids, visualEdit, fmt.Errorf("/remote:new error updating remote: %v", err))
|
||||
}
|
||||
@ -2367,19 +2367,19 @@ func RemoteConfigParseCommand(ctx context.Context, pk *scpacket.FeCommandPacketT
|
||||
editMap[sstore.RemoteField_SSHKey] = hostInfo.SshKeyFile
|
||||
}
|
||||
editMap[sstore.RemoteField_ShellPref] = hostInfo.ShellPref
|
||||
msh := remote.GetRemoteById(previouslyImportedRemote.RemoteId)
|
||||
if msh == nil {
|
||||
wsh := remote.GetRemoteById(previouslyImportedRemote.RemoteId)
|
||||
if wsh == nil {
|
||||
remoteChangeList["updateErr"] = append(remoteChangeList["updateErr"], hostInfo.CanonicalName)
|
||||
log.Printf("strange, msh for remote %s [%s] not found\n", hostInfo.CanonicalName, previouslyImportedRemote.RemoteId)
|
||||
log.Printf("strange, wsh for remote %s [%s] not found\n", hostInfo.CanonicalName, previouslyImportedRemote.RemoteId)
|
||||
continue
|
||||
}
|
||||
|
||||
if msh.Remote.ConnectMode == hostInfo.ConnectMode && msh.Remote.SSHOpts.SSHIdentity == hostInfo.SshKeyFile && msh.Remote.RemoteAlias == hostInfo.Host && msh.Remote.ShellPref == hostInfo.ShellPref {
|
||||
if wsh.Remote.ConnectMode == hostInfo.ConnectMode && wsh.Remote.SSHOpts.SSHIdentity == hostInfo.SshKeyFile && wsh.Remote.RemoteAlias == hostInfo.Host && wsh.Remote.ShellPref == hostInfo.ShellPref {
|
||||
// silently skip this one. it didn't fail, but no changes were needed
|
||||
continue
|
||||
}
|
||||
|
||||
err := msh.UpdateRemote(ctx, editMap)
|
||||
err := wsh.UpdateRemote(ctx, editMap)
|
||||
if err != nil {
|
||||
remoteChangeList["updateErr"] = append(remoteChangeList["updateErr"], hostInfo.CanonicalName)
|
||||
log.Printf("error updating remote[%s]: %v\n", hostInfo.CanonicalName, err)
|
||||
@ -2548,11 +2548,11 @@ func crShowCommand(ctx context.Context, pk *scpacket.FeCommandPacketType, ids re
|
||||
}
|
||||
for _, ri := range riArr {
|
||||
rptr := sstore.RemotePtrType{RemoteId: ri.RemoteId, Name: ri.Name}
|
||||
msh := remote.GetRemoteById(ri.RemoteId)
|
||||
if msh == nil {
|
||||
wsh := remote.GetRemoteById(ri.RemoteId)
|
||||
if wsh == nil {
|
||||
continue
|
||||
}
|
||||
baseDisplayName := msh.GetDisplayName()
|
||||
baseDisplayName := wsh.GetDisplayName()
|
||||
displayName := rptr.GetDisplayName(baseDisplayName)
|
||||
cwdStr := "-"
|
||||
if ri.FeState["cwd"] != "" {
|
||||
@ -3006,17 +3006,17 @@ func CrCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus.Upd
|
||||
if rstate.Archived {
|
||||
return nil, fmt.Errorf("/%s error: remote %q cannot switch to archived remote", GetCmdStr(pk), newRemote)
|
||||
}
|
||||
newMsh := remote.GetRemoteById(rptr.RemoteId)
|
||||
if newMsh == nil {
|
||||
return nil, fmt.Errorf("/%s error: remote %q not found (msh)", GetCmdStr(pk), newRemote)
|
||||
newWsh := remote.GetRemoteById(rptr.RemoteId)
|
||||
if newWsh == nil {
|
||||
return nil, fmt.Errorf("/%s error: remote %q not found (wsh)", GetCmdStr(pk), newRemote)
|
||||
}
|
||||
if !newMsh.IsConnected() {
|
||||
err := newMsh.TryAutoConnect()
|
||||
if !newWsh.IsConnected() {
|
||||
err := newWsh.TryAutoConnect()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%q is disconnected, auto-connect failed: %w", rstate.GetBaseDisplayName(), err)
|
||||
}
|
||||
if !newMsh.IsConnected() {
|
||||
if newMsh.GetRemoteCopy().ConnectMode == sstore.ConnectModeManual {
|
||||
if !newWsh.IsConnected() {
|
||||
if newWsh.GetRemoteCopy().ConnectMode == sstore.ConnectModeManual {
|
||||
return nil, fmt.Errorf("%q is disconnected (must manually connect)", rstate.GetBaseDisplayName())
|
||||
}
|
||||
return nil, fmt.Errorf("%q is disconnected", rstate.GetBaseDisplayName())
|
||||
@ -3057,7 +3057,7 @@ func CrCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus.Upd
|
||||
ScreenId: ids.ScreenId,
|
||||
RPtr: *rptr,
|
||||
}
|
||||
go doAsyncResetCommand(newMsh, opts, cmd)
|
||||
go doAsyncResetCommand(newWsh, opts, cmd)
|
||||
return update, nil
|
||||
} else {
|
||||
outputStr := fmt.Sprintf("reconnected to %s", GetFullRemoteDisplayName(rptr, rstate))
|
||||
@ -3298,7 +3298,7 @@ func doCompGen(ctx context.Context, pk *scpacket.FeCommandPacketType, prefix str
|
||||
cgPacket.CompType = compType
|
||||
cgPacket.Prefix = prefix
|
||||
cgPacket.Cwd = ids.Remote.FeState["cwd"]
|
||||
resp, err := ids.Remote.MShell.PacketRpc(ctx, cgPacket)
|
||||
resp, err := ids.Remote.Waveshell.PacketRpc(ctx, cgPacket)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
@ -3942,7 +3942,7 @@ func ClearSudoCache(ctx context.Context, pk *scpacket.FeCommandPacketType) (rtnU
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ids.Remote.MShell.ClearCachedSudoPw()
|
||||
ids.Remote.Waveshell.ClearCachedSudoPw()
|
||||
pluralize := ""
|
||||
|
||||
clearAll := resolveBool(pk.Kwargs["all"], false)
|
||||
@ -3966,7 +3966,7 @@ func RemoteResetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !ids.Remote.MShell.IsConnected() {
|
||||
if !ids.Remote.Waveshell.IsConnected() {
|
||||
return nil, fmt.Errorf("cannot reinit, remote is not connected")
|
||||
}
|
||||
verbose := resolveBool(pk.Kwargs["verbose"], false)
|
||||
@ -3994,7 +3994,7 @@ func RemoteResetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (
|
||||
ScreenId: ids.ScreenId,
|
||||
RPtr: ids.Remote.RemotePtr,
|
||||
}
|
||||
go doAsyncResetCommand(ids.Remote.MShell, opts, cmd)
|
||||
go doAsyncResetCommand(ids.Remote.Waveshell, opts, cmd)
|
||||
return update, nil
|
||||
}
|
||||
|
||||
@ -4007,7 +4007,7 @@ type connectOptsType struct {
|
||||
}
|
||||
|
||||
// this does the asynchroneous part of the connection reset
|
||||
func doAsyncResetCommand(msh *remote.MShellProc, opts connectOptsType, cmd *sstore.CmdType) {
|
||||
func doAsyncResetCommand(wsh *remote.WaveshellProc, opts connectOptsType, cmd *sstore.CmdType) {
|
||||
ctx, cancelFn := context.WithCancel(context.Background())
|
||||
defer cancelFn()
|
||||
startTime := time.Now()
|
||||
@ -4025,7 +4025,7 @@ func doAsyncResetCommand(msh *remote.MShellProc, opts connectOptsType, cmd *ssto
|
||||
writeStringToPty(ctx, cmd, string(data), &outputPos)
|
||||
}
|
||||
origStatePtr, _ := sstore.GetRemoteStatePtr(ctx, opts.SessionId, opts.ScreenId, opts.RPtr)
|
||||
ssPk, err := msh.ReInit(ctx, base.MakeCommandKey(cmd.ScreenId, cmd.LineId), opts.ShellType, dataFn, opts.Verbose)
|
||||
ssPk, err := wsh.ReInit(ctx, base.MakeCommandKey(cmd.ScreenId, cmd.LineId), opts.ShellType, dataFn, opts.Verbose)
|
||||
if err != nil {
|
||||
rtnErr = err
|
||||
return
|
||||
@ -4296,11 +4296,11 @@ func resizeRunningCommand(ctx context.Context, cmd *sstore.CmdType, newCols int)
|
||||
feInput := scpacket.MakeFeInputPacket()
|
||||
feInput.CK = base.MakeCommandKey(cmd.ScreenId, cmd.LineId)
|
||||
feInput.WinSize = &packet.WinSize{Rows: int(cmd.TermOpts.Rows), Cols: newCols}
|
||||
msh := remote.GetRemoteById(cmd.Remote.RemoteId)
|
||||
if msh == nil {
|
||||
wsh := remote.GetRemoteById(cmd.Remote.RemoteId)
|
||||
if wsh == nil {
|
||||
return fmt.Errorf("cannot resize, cmd remote not found")
|
||||
}
|
||||
err := msh.HandleFeInput(feInput)
|
||||
err := wsh.HandleFeInput(feInput)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -4421,12 +4421,12 @@ func LineRestartCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (
|
||||
if cmd.Status == sstore.CmdStatusRunning || cmd.Status == sstore.CmdStatusDetached {
|
||||
killCtx, cancel := context.WithTimeout(ctx, 2*time.Second)
|
||||
defer cancel()
|
||||
err = ids.Remote.MShell.KillRunningCommandAndWait(killCtx, base.MakeCommandKey(ids.ScreenId, lineId))
|
||||
err = ids.Remote.Waveshell.KillRunningCommandAndWait(killCtx, base.MakeCommandKey(ids.ScreenId, lineId))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
ids.Remote.MShell.ResetDataPos(base.MakeCommandKey(ids.ScreenId, lineId))
|
||||
ids.Remote.Waveshell.ResetDataPos(base.MakeCommandKey(ids.ScreenId, lineId))
|
||||
err = sstore.ClearCmdPtyFile(ctx, ids.ScreenId, lineId)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error clearing existing pty file: %v", err)
|
||||
@ -5065,8 +5065,8 @@ func ViewStatCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scb
|
||||
return nil, err
|
||||
}
|
||||
streamPk.StatOnly = true
|
||||
msh := ids.Remote.MShell
|
||||
iter, err := msh.StreamFile(ctx, streamPk)
|
||||
wsh := ids.Remote.Waveshell
|
||||
iter, err := wsh.StreamFile(ctx, streamPk)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("/view:stat error: %v", err)
|
||||
}
|
||||
@ -5116,8 +5116,8 @@ func ViewTestCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scb
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
msh := ids.Remote.MShell
|
||||
iter, err := msh.StreamFile(ctx, streamPk)
|
||||
wsh := ids.Remote.Waveshell
|
||||
iter, err := wsh.StreamFile(ctx, streamPk)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("/view:test error: %v", err)
|
||||
}
|
||||
@ -5413,8 +5413,8 @@ func EditTestCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scb
|
||||
} else {
|
||||
writePk.Path = filepath.Join(cwd, fileArg)
|
||||
}
|
||||
msh := ids.Remote.MShell
|
||||
iter, err := msh.PacketRpcIter(ctx, writePk)
|
||||
wsh := ids.Remote.Waveshell
|
||||
iter, err := wsh.PacketRpcIter(ctx, writePk)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("/edit:test error: %v", err)
|
||||
}
|
||||
@ -5433,7 +5433,7 @@ func EditTestCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scb
|
||||
dataPk := packet.MakeFileDataPacket(writePk.ReqId)
|
||||
dataPk.Data = []byte(content)
|
||||
dataPk.Eof = true
|
||||
err = msh.SendFileData(dataPk)
|
||||
err = wsh.SendFileData(dataPk)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("/edit:test error sending data packet: %v", err)
|
||||
}
|
||||
@ -5500,17 +5500,17 @@ func SignalCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus
|
||||
if !sigNameRe.MatchString(sigArg) {
|
||||
return nil, fmt.Errorf("invalid signal name/number: %q", sigArg)
|
||||
}
|
||||
msh := remote.GetRemoteById(cmd.Remote.RemoteId)
|
||||
if msh == nil {
|
||||
wsh := remote.GetRemoteById(cmd.Remote.RemoteId)
|
||||
if wsh == nil {
|
||||
return nil, fmt.Errorf("cannot send signal, no remote found for command")
|
||||
}
|
||||
if !msh.IsConnected() {
|
||||
if !wsh.IsConnected() {
|
||||
return nil, fmt.Errorf("cannot send signal, remote is not connected")
|
||||
}
|
||||
inputPk := scpacket.MakeFeInputPacket()
|
||||
inputPk.CK = base.MakeCommandKey(cmd.ScreenId, cmd.LineId)
|
||||
inputPk.SigName = sigArg
|
||||
err = msh.HandleFeInput(inputPk)
|
||||
err = wsh.HandleFeInput(inputPk)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot send signal: %v", err)
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ type resolvedIds struct {
|
||||
type ResolvedRemote struct {
|
||||
DisplayName string
|
||||
RemotePtr sstore.RemotePtrType
|
||||
MShell *remote.MShellProc
|
||||
Waveshell *remote.WaveshellProc
|
||||
RState remote.RemoteRuntimeState
|
||||
RemoteCopy *sstore.RemoteType
|
||||
ShellType string // default remote shell preference
|
||||
@ -201,11 +201,11 @@ func resolveRemoteArg(remoteArg string) (*sstore.RemotePtrType, error) {
|
||||
if rrUser != "" {
|
||||
return nil, fmt.Errorf("remoteusers not supported")
|
||||
}
|
||||
msh := remote.GetRemoteByArg(rrRemote)
|
||||
if msh == nil {
|
||||
wsh := remote.GetRemoteByArg(rrRemote)
|
||||
if wsh == nil {
|
||||
return nil, nil
|
||||
}
|
||||
rcopy := msh.GetRemoteCopy()
|
||||
rcopy := wsh.GetRemoteCopy()
|
||||
return &sstore.RemotePtrType{RemoteId: rcopy.RemoteId, Name: rrName}, nil
|
||||
}
|
||||
|
||||
@ -269,7 +269,7 @@ func resolveUiIds(ctx context.Context, pk *scpacket.FeCommandPacketType, rtype i
|
||||
}
|
||||
if rtype&R_RemoteConnected > 0 {
|
||||
if !rtn.Remote.RState.IsConnected() {
|
||||
err = rtn.Remote.MShell.TryAutoConnect()
|
||||
err = rtn.Remote.Waveshell.TryAutoConnect()
|
||||
if err != nil {
|
||||
return rtn, fmt.Errorf("error trying to auto-connect remote [%s]: %w", rtn.Remote.DisplayName, err)
|
||||
}
|
||||
@ -464,18 +464,18 @@ func ResolveRemoteFromPtr(ctx context.Context, rptr *sstore.RemotePtrType, sessi
|
||||
if rptr == nil || rptr.RemoteId == "" {
|
||||
return nil, nil
|
||||
}
|
||||
msh := remote.GetRemoteById(rptr.RemoteId)
|
||||
if msh == nil {
|
||||
wsh := remote.GetRemoteById(rptr.RemoteId)
|
||||
if wsh == nil {
|
||||
return nil, fmt.Errorf("invalid remote '%s', not found", rptr.RemoteId)
|
||||
}
|
||||
rstate := msh.GetRemoteRuntimeState()
|
||||
rcopy := msh.GetRemoteCopy()
|
||||
rstate := wsh.GetRemoteRuntimeState()
|
||||
rcopy := wsh.GetRemoteCopy()
|
||||
displayName := rstate.GetDisplayName(rptr)
|
||||
rtn := &ResolvedRemote{
|
||||
DisplayName: displayName,
|
||||
RemotePtr: *rptr,
|
||||
RState: rstate,
|
||||
MShell: msh,
|
||||
Waveshell: wsh,
|
||||
RemoteCopy: &rcopy,
|
||||
StatePtr: nil,
|
||||
FeState: nil,
|
||||
@ -488,7 +488,7 @@ func ResolveRemoteFromPtr(ctx context.Context, rptr *sstore.RemotePtrType, sessi
|
||||
// continue with state set to nil
|
||||
} else {
|
||||
if ri == nil {
|
||||
rtn.ShellType = msh.GetShellPref()
|
||||
rtn.ShellType = wsh.GetShellPref()
|
||||
rtn.StatePtr = nil
|
||||
rtn.FeState = nil
|
||||
} else {
|
||||
|
@ -65,8 +65,8 @@ func doCompGen(ctx context.Context, prefix string, compType string, compCtx Comp
|
||||
if !packet.IsValidCompGenType(compType) {
|
||||
return nil, fmt.Errorf("/_compgen invalid type '%s'", compType)
|
||||
}
|
||||
msh := remote.GetRemoteById(compCtx.RemotePtr.RemoteId)
|
||||
if msh == nil {
|
||||
wsh := remote.GetRemoteById(compCtx.RemotePtr.RemoteId)
|
||||
if wsh == nil {
|
||||
return nil, fmt.Errorf("invalid remote '%s', not found", compCtx.RemotePtr)
|
||||
}
|
||||
cgPacket := packet.MakeCompGenPacket()
|
||||
@ -74,7 +74,7 @@ func doCompGen(ctx context.Context, prefix string, compType string, compCtx Comp
|
||||
cgPacket.CompType = compType
|
||||
cgPacket.Prefix = prefix
|
||||
cgPacket.Cwd = compCtx.Cwd
|
||||
resp, err := msh.PacketRpc(ctx, cgPacket)
|
||||
resp, err := wsh.PacketRpc(ctx, cgPacket)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -36,7 +36,7 @@ const WaveDirName = ".waveterm" // must match emain.ts
|
||||
const WaveDevDirName = ".waveterm-dev" // must match emain.ts
|
||||
const WaveAppPathVarName = "WAVETERM_APP_PATH"
|
||||
const WaveAuthKeyFileName = "waveterm.authkey"
|
||||
const MShellVersion = "v0.7.0" // must match base.MShellVersion
|
||||
const WaveshellVersion = "v0.7.0" // must match base.WaveshellVersion
|
||||
|
||||
// initialized by InitialzeWaveAuthKey (called by main-server)
|
||||
var WaveAuthKey string
|
||||
@ -73,7 +73,7 @@ func GetWaveHomeDir() string {
|
||||
return scHome
|
||||
}
|
||||
|
||||
func MShellBinaryDir() string {
|
||||
func WaveshellBinaryDir() string {
|
||||
appPath := os.Getenv(WaveAppPathVarName)
|
||||
if appPath == "" {
|
||||
appPath = "."
|
||||
@ -81,32 +81,32 @@ func MShellBinaryDir() string {
|
||||
return filepath.Join(appPath, "bin", "mshell")
|
||||
}
|
||||
|
||||
func MShellBinaryPath(version string, goos string, goarch string) (string, error) {
|
||||
func WaveshellBinaryPath(version string, goos string, goarch string) (string, error) {
|
||||
if !base.ValidGoArch(goos, goarch) {
|
||||
return "", fmt.Errorf("invalid goos/goarch combination: %s/%s", goos, goarch)
|
||||
}
|
||||
binaryDir := MShellBinaryDir()
|
||||
binaryDir := WaveshellBinaryDir()
|
||||
versionStr := semver.MajorMinor(version)
|
||||
if versionStr == "" {
|
||||
return "", fmt.Errorf("invalid mshell version: %q", version)
|
||||
return "", fmt.Errorf("invalid waveshell version: %q", version)
|
||||
}
|
||||
fileName := fmt.Sprintf("mshell-%s-%s.%s", versionStr, goos, goarch)
|
||||
fullFileName := filepath.Join(binaryDir, fileName)
|
||||
return fullFileName, nil
|
||||
}
|
||||
|
||||
func LocalMShellBinaryPath() (string, error) {
|
||||
return MShellBinaryPath(MShellVersion, runtime.GOOS, runtime.GOARCH)
|
||||
func LocalWaveshellBinaryPath() (string, error) {
|
||||
return WaveshellBinaryPath(WaveshellVersion, runtime.GOOS, runtime.GOARCH)
|
||||
}
|
||||
|
||||
func MShellBinaryReader(version string, goos string, goarch string) (io.ReadCloser, error) {
|
||||
mshellPath, err := MShellBinaryPath(version, goos, goarch)
|
||||
func WaveshellBinaryReader(version string, goos string, goarch string) (io.ReadCloser, error) {
|
||||
waveshellPath, err := WaveshellBinaryPath(version, goos, goarch)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fd, err := os.Open(mshellPath)
|
||||
fd, err := os.Open(waveshellPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot open mshell binary %q: %v", mshellPath, err)
|
||||
return nil, fmt.Errorf("cannot open waveshell binary %q: %v", waveshellPath, err)
|
||||
}
|
||||
return fd, nil
|
||||
}
|
||||
|
@ -326,9 +326,9 @@ func sendCmdInput(pk *scpacket.FeInputPacketType) error {
|
||||
if pk.Remote.RemoteId == "" {
|
||||
return fmt.Errorf("input must set remoteid")
|
||||
}
|
||||
msh := remote.GetRemoteById(pk.Remote.RemoteId)
|
||||
if msh == nil {
|
||||
wsh := remote.GetRemoteById(pk.Remote.RemoteId)
|
||||
if wsh == nil {
|
||||
return fmt.Errorf("remote %s not found", pk.Remote.RemoteId)
|
||||
}
|
||||
return msh.HandleFeInput(pk)
|
||||
return wsh.HandleFeInput(pk)
|
||||
}
|
||||
|
@ -751,10 +751,10 @@ func UpdateCmdForRestart(ctx context.Context, ck base.CommandKey, ts int64, cmdP
|
||||
})
|
||||
}
|
||||
|
||||
func UpdateCmdStartInfo(ctx context.Context, ck base.CommandKey, cmdPid int, mshellPid int) error {
|
||||
func UpdateCmdStartInfo(ctx context.Context, ck base.CommandKey, cmdPid int, waveshellPid int) error {
|
||||
return WithTx(ctx, func(tx *TxWrap) error {
|
||||
query := `UPDATE cmd SET cmdpid = ?, remotepid = ? WHERE screenid = ? AND lineid = ?`
|
||||
tx.Exec(query, cmdPid, mshellPid, ck.GetGroupId(), lineIdFromCK(ck))
|
||||
tx.Exec(query, cmdPid, waveshellPid, ck.GetGroupId(), lineIdFromCK(ck))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
@ -758,34 +758,34 @@ const (
|
||||
)
|
||||
|
||||
type RemoteRuntimeState struct {
|
||||
RemoteType string `json:"remotetype"`
|
||||
RemoteId string `json:"remoteid"`
|
||||
RemoteAlias string `json:"remotealias,omitempty"`
|
||||
RemoteCanonicalName string `json:"remotecanonicalname"`
|
||||
RemoteVars map[string]string `json:"remotevars"`
|
||||
Status string `json:"status"`
|
||||
ConnectTimeout int `json:"connecttimeout,omitempty"`
|
||||
CountdownActive bool `json:"countdownactive"`
|
||||
ErrorStr string `json:"errorstr,omitempty"`
|
||||
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"`
|
||||
RemoteIdx int64 `json:"remoteidx"`
|
||||
SSHConfigSrc string `json:"sshconfigsrc"`
|
||||
UName string `json:"uname"`
|
||||
MShellVersion string `json:"mshellversion"`
|
||||
WaitingForPassword bool `json:"waitingforpassword,omitempty"`
|
||||
Local bool `json:"local,omitempty"`
|
||||
IsSudo bool `json:"issudo,omitempty"`
|
||||
RemoteOpts *RemoteOptsType `json:"remoteopts,omitempty"`
|
||||
CanComplete bool `json:"cancomplete,omitempty"`
|
||||
ShellPref string `json:"shellpref,omitempty"`
|
||||
DefaultShellType string `json:"defaultshelltype,omitempty"`
|
||||
RemoteType string `json:"remotetype"`
|
||||
RemoteId string `json:"remoteid"`
|
||||
RemoteAlias string `json:"remotealias,omitempty"`
|
||||
RemoteCanonicalName string `json:"remotecanonicalname"`
|
||||
RemoteVars map[string]string `json:"remotevars"`
|
||||
Status string `json:"status"`
|
||||
ConnectTimeout int `json:"connecttimeout,omitempty"`
|
||||
CountdownActive bool `json:"countdownactive"`
|
||||
ErrorStr string `json:"errorstr,omitempty"`
|
||||
InstallStatus string `json:"installstatus"`
|
||||
InstallErrorStr string `json:"installerrorstr,omitempty"`
|
||||
NeedsWaveshellUpgrade bool `json:"needswaveshellupgrade,omitempty"`
|
||||
NoInitPk bool `json:"noinitpk,omitempty"`
|
||||
AuthType string `json:"authtype,omitempty"`
|
||||
ConnectMode string `json:"connectmode"`
|
||||
AutoInstall bool `json:"autoinstall"`
|
||||
Archived bool `json:"archived,omitempty"`
|
||||
RemoteIdx int64 `json:"remoteidx"`
|
||||
SSHConfigSrc string `json:"sshconfigsrc"`
|
||||
UName string `json:"uname"`
|
||||
WaveshellVersion string `json:"waveshellversion"`
|
||||
WaitingForPassword bool `json:"waitingforpassword,omitempty"`
|
||||
Local bool `json:"local,omitempty"`
|
||||
IsSudo bool `json:"issudo,omitempty"`
|
||||
RemoteOpts *RemoteOptsType `json:"remoteopts,omitempty"`
|
||||
CanComplete bool `json:"cancomplete,omitempty"`
|
||||
ShellPref string `json:"shellpref,omitempty"`
|
||||
DefaultShellType string `json:"defaultshelltype,omitempty"`
|
||||
}
|
||||
|
||||
func (state RemoteRuntimeState) IsConnected() bool {
|
||||
|
Loading…
Reference in New Issue
Block a user