Documentation ¶
Index ¶
- Constants
- func AddRemote(ctx context.Context, r *sstore.RemoteType, shouldStart bool) error
- func ArchiveRemote(ctx context.Context, remoteId string) error
- func CanComplete(remoteType string) bool
- func ConnectToClient(connCtx context.Context, opts *sstore.SSHOpts, remoteDisplayName string) (*ssh.Client, error)
- func DialContext(ctx context.Context, network string, addr string, config *ssh.ClientConfig) (*ssh.Client, error)
- func EvalPrompt(promptFmt string, vars map[string]string, state *packet.ShellState) string
- func GetRemoteCopyById(remoteId string) *sstore.RemoteType
- func GetRemoteMap() map[string]*WaveshellProc
- func LoadRemoteById(ctx context.Context, remoteId string) error
- func LoadRemotes(ctx context.Context) error
- func MakeLocalWaveshellCommandStr(isSudo bool) (string, error)
- func MakeServerCommandStr() string
- func NumRemotes() int
- func ReadRemotePty(ctx context.Context, remoteId string) (int64, []byte, error)
- func RunCommand(ctx context.Context, rcOpts RunCommandOpts, runPacket *packet.RunPacketType) (rtnCmd *sstore.CmdType, rtnCallback func(), rtnErr error)
- func SendRemoteInput(pk *scpacket.RemoteInputPacketType) error
- func SendSignalToCmd(ctx context.Context, cmd *sstore.CmdType, sig string) error
- type CircleLog
- type CommandInputSink
- type ReinitCommandSink
- type RemoteRuntimeState
- type RunCmdType
- type RunCommandOpts
- type SshKeywords
- type Store
- type UserInputCancelError
- type WaveshellProc
- func (wsh *WaveshellProc) AddRunningCmd(rct *RunCmdType)
- func (wsh *WaveshellProc) CancelInstall()
- func (wsh *WaveshellProc) ChangeSudoTimeout(deltaTime int64)
- func (wsh *WaveshellProc) CheckPasswordRequested(ctx context.Context, requiresPassword chan bool)
- func (wsh *WaveshellProc) ClearCachedSudoPw()
- func (wsh *WaveshellProc) Disconnect(force bool)
- func (wsh *WaveshellProc) GetDisplayName() string
- func (wsh *WaveshellProc) GetInstallStatus() string
- func (wsh *WaveshellProc) GetNumRunningCommands() int
- func (wsh *WaveshellProc) GetRemoteCopy() sstore.RemoteType
- func (wsh *WaveshellProc) GetRemoteId() string
- func (wsh *WaveshellProc) GetRemoteName() string
- func (wsh *WaveshellProc) GetRemoteRuntimeState() RemoteRuntimeState
- func (wsh *WaveshellProc) GetRunningCmd(ck base.CommandKey) *RunCmdType
- func (wsh *WaveshellProc) GetShellPref() string
- func (wsh *WaveshellProc) GetShellType() string
- func (wsh *WaveshellProc) GetStatus() string
- func (wsh *WaveshellProc) GetUName() string
- func (wsh *WaveshellProc) HandleFeInput(inputPk *scpacket.FeInputPacketType) error
- func (wsh *WaveshellProc) IsCmdRunning(ck base.CommandKey) bool
- func (wsh *WaveshellProc) IsConnected() bool
- func (wsh *WaveshellProc) IsLocal() bool
- func (wsh *WaveshellProc) IsSudo() bool
- func (wsh *WaveshellProc) KillRunningCommandAndWait(ctx context.Context, ck base.CommandKey) error
- func (wsh *WaveshellProc) Launch(interactive bool)
- func (wsh *WaveshellProc) NotifyRemoteUpdate()
- func (wsh *WaveshellProc) PacketRpc(ctx context.Context, pk packet.RpcPacketType) (*packet.ResponsePacketType, error)
- func (wsh *WaveshellProc) PacketRpcIter(ctx context.Context, pk packet.RpcPacketType) (*packet.RpcResponseIter, error)
- func (wsh *WaveshellProc) PacketRpcRaw(ctx context.Context, pk packet.RpcPacketType) (packet.RpcResponsePacketType, error)
- func (wsh *WaveshellProc) ProcessPackets()
- func (wsh *WaveshellProc) ReInit(ctx context.Context, ck base.CommandKey, shellType string, dataFn func([]byte), ...) (rtnPk *packet.ShellStatePacketType, rtnErr error)
- func (wsh *WaveshellProc) RemoveRunningCmd(ck base.CommandKey)
- func (wsh *WaveshellProc) ResetDataPos(ck base.CommandKey)
- func (wsh *WaveshellProc) RunInstall(autoInstall bool)
- func (wsh *WaveshellProc) RunPasswordReadLoop(cmdPty *os.File)
- func (wsh *WaveshellProc) RunPtyReadLoop(cmdPty *os.File)
- func (wsh *WaveshellProc) SendFileData(dataPk *packet.FileDataPacketType) error
- func (wsh *WaveshellProc) SendPassword(pw string)
- func (wsh *WaveshellProc) StreamFile(ctx context.Context, streamPk *packet.StreamFilePacketType) (*packet.RpcResponseIter, error)
- func (wsh *WaveshellProc) TryAutoConnect() error
- func (wsh *WaveshellProc) UpdateRemote(ctx context.Context, editMap map[string]interface{}) error
- func (wsh *WaveshellProc) WaitAndSendPassword(pw string)
- func (wsh *WaveshellProc) WaitAndSendPasswordNew(pw string)
- func (wsh *WaveshellProc) WithLock(fn func())
- func (wsh *WaveshellProc) WriteFile(ctx context.Context, writePk *packet.WriteFilePacketType) (*packet.RpcResponseIter, error)
- func (wsh *WaveshellProc) WriteToPtyBuffer(strFmt string, args ...interface{})
Constants ¶
const ( StatusConnected = sstore.RemoteStatus_Connected StatusConnecting = sstore.RemoteStatus_Connecting StatusDisconnected = sstore.RemoteStatus_Disconnected StatusError = sstore.RemoteStatus_Error )
const CircBufSize = 64 * 1024
const DefaultMaxPtySize = 1024 * 1024
const DefaultTerm = "xterm-256color"
const MaxInputDataSize = 1000
const NewStateDiffSizeThreshold = 30 * 1024
after this limit we'll switch to persisting the full state
const PrintPingPacket = `printf "\n##N{\"type\": \"ping\"}\n"`
we add this ping packet to the WaveshellServer Commands in order to deal with spurious SSH output basically we guarantee the parser will see a valid packet (either an init error or a ping) so we can pass ignoreUntilValid to PacketParser
const PtyReadBufSize = 100
const RemoteConnectTimeout = 15 * time.Second
const RemoteTermCols = 80
const RemoteTermRows = 8
const RemoteTypeWaveshell = "mshell"
const RpcIterChannelSize = 100
const SudoTimeoutTime = 5 * time.Minute
const WaveshellServerCommandFmt = `` /* 252-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func CanComplete ¶
func ConnectToClient ¶
func DialContext ¶
func EvalPrompt ¶
func GetRemoteCopyById ¶
func GetRemoteCopyById(remoteId string) *sstore.RemoteType
func GetRemoteMap ¶
func GetRemoteMap() map[string]*WaveshellProc
func LoadRemotes ¶
func MakeServerCommandStr ¶
func MakeServerCommandStr() string
func NumRemotes ¶
func NumRemotes() int
func ReadRemotePty ¶
func RunCommand ¶
func RunCommand(ctx context.Context, rcOpts RunCommandOpts, runPacket *packet.RunPacketType) (rtnCmd *sstore.CmdType, rtnCallback func(), rtnErr error)
returns (CmdType, allow-updates-callback, err) we must persist the CmdType to the DB before calling the callback to allow updates otherwise an early CmdDone packet might not get processed (since cmd will not exist in DB)
func SendRemoteInput ¶
func SendRemoteInput(pk *scpacket.RemoteInputPacketType) error
Types ¶
type CommandInputSink ¶
type CommandInputSink interface {
HandleInput(feInput *scpacket.FeInputPacketType) error
}
type ReinitCommandSink ¶
type ReinitCommandSink struct { Remote *WaveshellProc ReqId string }
func (*ReinitCommandSink) HandleInput ¶
func (rcs *ReinitCommandSink) HandleInput(feInput *scpacket.FeInputPacketType) error
type RemoteRuntimeState ¶
type RemoteRuntimeState = sstore.RemoteRuntimeState
func GetAllRemoteRuntimeState ¶
func GetAllRemoteRuntimeState() []*RemoteRuntimeState
func ResolveRemoteRef ¶
func ResolveRemoteRef(remoteRef string) *RemoteRuntimeState
type RunCmdType ¶
type RunCmdType struct { CK base.CommandKey SessionId string ScreenId string RemotePtr sstore.RemotePtrType RunPacket *packet.RunPacketType EphemeralOpts *ephemeral.EphemeralRunOpts }
type RunCommandOpts ¶
type RunCommandOpts struct { SessionId string ScreenId string RemotePtr sstore.RemotePtrType // optional, if not provided shellstate will look up state from remote instance // ReturnState cannot be used with StatePtr // this will also cause this command to bypass the pending state cmd logic StatePtr *packet.ShellStatePtr // set to true to skip creating the pty file (for restarted commands) NoCreateCmdPtyFile bool // this command will not go into the DB, and will not have a ptyout file created // forces special packet handling (sets RunCommandType.EphemeralOpts) EphemeralOpts *ephemeral.EphemeralRunOpts }
type SshKeywords ¶
type Store ¶
type Store struct { Lock *sync.Mutex Map map[string]*WaveshellProc // key=remoteid CmdWaitMap map[base.CommandKey][]func() }
var GlobalStore *Store
type UserInputCancelError ¶
type UserInputCancelError struct {
Err error
}
func (UserInputCancelError) Error ¶
func (uice UserInputCancelError) Error() string
type WaveshellProc ¶
type WaveshellProc struct { Lock *sync.Mutex Remote *sstore.RemoteType // runtime RemoteId string // can be read without a lock Status string ServerProc *shexec.ClientProc // the server process UName string Err error ErrNoInitPk bool ControllingPty *os.File PtyBuffer *circbuf.Buffer MakeClientCancelFn context.CancelFunc MakeClientDeadline *time.Time StateMap *server.ShellStateMap NumTryConnect int InitPkShellType string DataPosMap *utilfn.SyncMap[base.CommandKey, int64] // install InstallStatus string NeedsWaveshellUpgrade bool InstallCancelFn context.CancelFunc InstallErr error // for synthetic commands (not run through RunCommand), this provides a way for them // to register to receive input events from the frontend (e.g. ReInit) CommandInputMap map[base.CommandKey]CommandInputSink RunningCmds map[base.CommandKey]*RunCmdType PendingStateCmds map[pendingStateKey]base.CommandKey // key=[remoteinstance name] (in progress commands that might update the state) Client *ssh.Client // contains filtered or unexported fields }
provides state, acccess, and control for a waveshell server process
func GetLocalRemote ¶
func GetLocalRemote() *WaveshellProc
func GetRemoteByArg ¶
func GetRemoteByArg(arg string) *WaveshellProc
func GetRemoteById ¶
func GetRemoteById(remoteId string) *WaveshellProc
func MakeWaveshell ¶
func MakeWaveshell(r *sstore.RemoteType) *WaveshellProc
func (*WaveshellProc) AddRunningCmd ¶
func (wsh *WaveshellProc) AddRunningCmd(rct *RunCmdType)
func (*WaveshellProc) CancelInstall ¶
func (wsh *WaveshellProc) CancelInstall()
func (*WaveshellProc) ChangeSudoTimeout ¶
func (wsh *WaveshellProc) ChangeSudoTimeout(deltaTime int64)
func (*WaveshellProc) CheckPasswordRequested ¶
func (wsh *WaveshellProc) CheckPasswordRequested(ctx context.Context, requiresPassword chan bool)
func (*WaveshellProc) ClearCachedSudoPw ¶
func (wsh *WaveshellProc) ClearCachedSudoPw()
func (*WaveshellProc) Disconnect ¶
func (wsh *WaveshellProc) Disconnect(force bool)
func (*WaveshellProc) GetDisplayName ¶
func (wsh *WaveshellProc) GetDisplayName() string
func (*WaveshellProc) GetInstallStatus ¶
func (wsh *WaveshellProc) GetInstallStatus() string
func (*WaveshellProc) GetNumRunningCommands ¶
func (wsh *WaveshellProc) GetNumRunningCommands() int
func (*WaveshellProc) GetRemoteCopy ¶
func (wsh *WaveshellProc) GetRemoteCopy() sstore.RemoteType
func (*WaveshellProc) GetRemoteId ¶
func (wsh *WaveshellProc) GetRemoteId() string
func (*WaveshellProc) GetRemoteName ¶
func (wsh *WaveshellProc) GetRemoteName() string
func (*WaveshellProc) GetRemoteRuntimeState ¶
func (wsh *WaveshellProc) GetRemoteRuntimeState() RemoteRuntimeState
func (*WaveshellProc) GetRunningCmd ¶
func (wsh *WaveshellProc) GetRunningCmd(ck base.CommandKey) *RunCmdType
func (*WaveshellProc) GetShellPref ¶
func (wsh *WaveshellProc) GetShellPref() string
if wsh.IsConnected() then GetShellPref() should return a valid shell if wsh is not connected, then InitPkShellType might be empty
func (*WaveshellProc) GetShellType ¶
func (wsh *WaveshellProc) GetShellType() string
func (*WaveshellProc) GetStatus ¶
func (wsh *WaveshellProc) GetStatus() string
func (*WaveshellProc) GetUName ¶
func (wsh *WaveshellProc) GetUName() string
func (*WaveshellProc) HandleFeInput ¶
func (wsh *WaveshellProc) HandleFeInput(inputPk *scpacket.FeInputPacketType) error
func (*WaveshellProc) IsCmdRunning ¶
func (wsh *WaveshellProc) IsCmdRunning(ck base.CommandKey) bool
func (*WaveshellProc) IsConnected ¶
func (wsh *WaveshellProc) IsConnected() bool
func (*WaveshellProc) IsLocal ¶
func (wsh *WaveshellProc) IsLocal() bool
func (*WaveshellProc) IsSudo ¶
func (wsh *WaveshellProc) IsSudo() bool
func (*WaveshellProc) KillRunningCommandAndWait ¶
func (wsh *WaveshellProc) KillRunningCommandAndWait(ctx context.Context, ck base.CommandKey) error
func (*WaveshellProc) Launch ¶
func (wsh *WaveshellProc) Launch(interactive bool)
func (*WaveshellProc) NotifyRemoteUpdate ¶
func (wsh *WaveshellProc) NotifyRemoteUpdate()
func (*WaveshellProc) PacketRpc ¶
func (wsh *WaveshellProc) PacketRpc(ctx context.Context, pk packet.RpcPacketType) (*packet.ResponsePacketType, error)
func (*WaveshellProc) PacketRpcIter ¶
func (wsh *WaveshellProc) PacketRpcIter(ctx context.Context, pk packet.RpcPacketType) (*packet.RpcResponseIter, error)
func (*WaveshellProc) PacketRpcRaw ¶
func (wsh *WaveshellProc) PacketRpcRaw(ctx context.Context, pk packet.RpcPacketType) (packet.RpcResponsePacketType, error)
func (*WaveshellProc) ProcessPackets ¶
func (wsh *WaveshellProc) ProcessPackets()
func (*WaveshellProc) ReInit ¶
func (wsh *WaveshellProc) ReInit(ctx context.Context, ck base.CommandKey, shellType string, dataFn func([]byte), verbose bool) (rtnPk *packet.ShellStatePacketType, rtnErr error)
func (*WaveshellProc) RemoveRunningCmd ¶
func (wsh *WaveshellProc) RemoveRunningCmd(ck base.CommandKey)
func (*WaveshellProc) ResetDataPos ¶
func (wsh *WaveshellProc) ResetDataPos(ck base.CommandKey)
func (*WaveshellProc) RunInstall ¶
func (wsh *WaveshellProc) RunInstall(autoInstall bool)
func (*WaveshellProc) RunPasswordReadLoop ¶
func (wsh *WaveshellProc) RunPasswordReadLoop(cmdPty *os.File)
func (*WaveshellProc) RunPtyReadLoop ¶
func (wsh *WaveshellProc) RunPtyReadLoop(cmdPty *os.File)
func (*WaveshellProc) SendFileData ¶
func (wsh *WaveshellProc) SendFileData(dataPk *packet.FileDataPacketType) error
func (*WaveshellProc) SendPassword ¶
func (wsh *WaveshellProc) SendPassword(pw string)
func (*WaveshellProc) StreamFile ¶
func (wsh *WaveshellProc) StreamFile(ctx context.Context, streamPk *packet.StreamFilePacketType) (*packet.RpcResponseIter, error)
func (*WaveshellProc) TryAutoConnect ¶
func (wsh *WaveshellProc) TryAutoConnect() error
func (*WaveshellProc) UpdateRemote ¶
func (wsh *WaveshellProc) UpdateRemote(ctx context.Context, editMap map[string]interface{}) error
func (*WaveshellProc) WaitAndSendPassword ¶
func (wsh *WaveshellProc) WaitAndSendPassword(pw string)
func (*WaveshellProc) WaitAndSendPasswordNew ¶
func (wsh *WaveshellProc) WaitAndSendPasswordNew(pw string)
func (*WaveshellProc) WithLock ¶
func (wsh *WaveshellProc) WithLock(fn func())
func (*WaveshellProc) WriteFile ¶
func (wsh *WaveshellProc) WriteFile(ctx context.Context, writePk *packet.WriteFilePacketType) (*packet.RpcResponseIter, error)
func (*WaveshellProc) WriteToPtyBuffer ¶
func (wsh *WaveshellProc) WriteToPtyBuffer(strFmt string, args ...interface{})