{"modulePath":"github.com/wavetermdev/waveterm/wavesrv","version":"v0.7.6","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package remote\n\n## Constants\n\n```go\nconst (\n\tStatusConnected    = sstore.RemoteStatus_Connected\n\tStatusConnecting   = sstore.RemoteStatus_Connecting\n\tStatusDisconnected = sstore.RemoteStatus_Disconnected\n\tStatusError        = sstore.RemoteStatus_Error\n)\n```\n\n```go\nconst CircBufSize = 64 * 1024\n```\n\n```go\nconst DefaultMaxPtySize = 1024 * 1024\n```\n\n```go\nconst DefaultTerm = \"xterm-256color\"\n```\n\n```go\nconst MaxInputDataSize = 1000\n```\n\n```go\nconst NewStateDiffSizeThreshold = 30 * 1024\n```\nafter this limit we'll switch to persisting the full state\n\n```go\nconst PrintPingPacket = `printf \"\\n##N{\\\"type\\\": \\\"ping\\\"}\\n\"`\n```\nwe 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\n\n```go\nconst PtyReadBufSize = 100\n```\n\n```go\nconst RemoteConnectTimeout = 15 * time.Second\n```\n\n```go\nconst RemoteTermCols = 80\n```\n\n```go\nconst RemoteTermRows = 8\n```\n\n```go\nconst RemoteTypeWaveshell = \"mshell\"\n```\n\n```go\nconst RpcIterChannelSize = 100\n```\n\n```go\nconst SudoTimeoutTime = 5 * time.Minute\n```\n\n```go\nconst WaveshellServerCommandFmt = `\nPATH=$PATH:~/.mshell;\nwhich mshell-[%VERSION%] \u003e /dev/null;\nif [[ \"$?\" -ne 0 ]]\nthen\n  printf \"\\n##N{\\\"type\\\": \\\"init\\\", \\\"notfound\\\": true, \\\"uname\\\": \\\"%s | %s\\\"}\\n\" \"$(uname -s)\" \"$(uname -m)\"\nelse\n  [%PINGPACKET%]\n  mshell-[%VERSION%] --server\nfi\n`\n```\n\n## Functions\n\n```go\nfunc AddRemote(ctx context.Context, r *sstore.RemoteType, shouldStart bool) error\n```\n\n```go\nfunc ArchiveRemote(ctx context.Context, remoteId string) error\n```\n\n```go\nfunc CanComplete(remoteType string) bool\n```\n\n```go\nfunc ConnectToClient(connCtx context.Context, opts *sstore.SSHOpts, remoteDisplayName string) (*ssh.Client, error)\n```\n\n```go\nfunc DialContext(ctx context.Context, network string, addr string, config *ssh.ClientConfig) (*ssh.Client, error)\n```\n\n```go\nfunc EvalPrompt(promptFmt string, vars map[string]string, state *packet.ShellState) string\n```\n\n```go\nfunc GetRemoteCopyById(remoteId string) *sstore.RemoteType\n```\n\n```go\nfunc GetRemoteMap() map[string]*WaveshellProc\n```\n\n```go\nfunc LoadRemoteById(ctx context.Context, remoteId string) error\n```\n\n```go\nfunc LoadRemotes(ctx context.Context) error\n```\n\n```go\nfunc MakeLocalWaveshellCommandStr(isSudo bool) (string, error)\n```\n\n```go\nfunc MakeServerCommandStr() string\n```\n\n```go\nfunc NumRemotes() int\n```\n\n```go\nfunc ReadRemotePty(ctx context.Context, remoteId string) (int64, []byte, error)\n```\n\n```go\nfunc RunCommand(ctx context.Context, rcOpts RunCommandOpts, runPacket *packet.RunPacketType) (rtnCmd *sstore.CmdType, rtnCallback func(), rtnErr error)\n```\nreturns (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)\n\n```go\nfunc SendRemoteInput(pk *scpacket.RemoteInputPacketType) error\n```\n\n```go\nfunc SendSignalToCmd(ctx context.Context, cmd *sstore.CmdType, sig string) error\n```\n\n## Types\n\n```go\ntype CircleLog struct {\n\tLock     *sync.Mutex\n\tStartPos int\n\tLog      []string\n\tMaxSize  int\n}\n```\n\n```go\nfunc MakeCircleLog(maxSize int) *CircleLog\n```\n\n```go\nfunc (l *CircleLog) Add(s string)\n```\n\n```go\nfunc (l *CircleLog) Addf(sfmt string, args ...interface{})\n```\n\n```go\nfunc (l *CircleLog) GetEntries() []string\n```\n\n```go\ntype CommandInputSink interface {\n\tHandleInput(feInput *scpacket.FeInputPacketType) error\n}\n```\n\n```go\ntype ReinitCommandSink struct {\n\tRemote *WaveshellProc\n\tReqId  string\n}\n```\n\n```go\nfunc (rcs *ReinitCommandSink) HandleInput(feInput *scpacket.FeInputPacketType) error\n```\n\n```go\ntype RemoteRuntimeState = sstore.RemoteRuntimeState\n```\n\n```go\nfunc GetAllRemoteRuntimeState() []*RemoteRuntimeState\n```\n\n```go\nfunc ResolveRemoteRef(remoteRef string) *RemoteRuntimeState\n```\n\n```go\ntype RunCmdType struct {\n\tCK            base.CommandKey\n\tSessionId     string\n\tScreenId      string\n\tRemotePtr     sstore.RemotePtrType\n\tRunPacket     *packet.RunPacketType\n\tEphemeralOpts *ephemeral.EphemeralRunOpts\n}\n```\n\n```go\ntype RunCommandOpts struct {\n\tSessionId string\n\tScreenId  string\n\tRemotePtr sstore.RemotePtrType\n\n\t// optional, if not provided shellstate will look up state from remote instance\n\t// ReturnState cannot be used with StatePtr\n\t// this will also cause this command to bypass the pending state cmd logic\n\tStatePtr *packet.ShellStatePtr\n\n\t// set to true to skip creating the pty file (for restarted commands)\n\tNoCreateCmdPtyFile bool\n\n\t// this command will not go into the DB, and will not have a ptyout file created\n\t// forces special packet handling (sets RunCommandType.EphemeralOpts)\n\tEphemeralOpts *ephemeral.EphemeralRunOpts\n}\n```\n\n```go\ntype SshKeywords struct {\n\tUser                         string\n\tHostName                     string\n\tPort                         string\n\tIdentityFile                 []string\n\tBatchMode                    bool\n\tPubkeyAuthentication         bool\n\tPasswordAuthentication       bool\n\tKbdInteractiveAuthentication bool\n\tPreferredAuthentications     []string\n}\n```\n\n```go\ntype Store struct {\n\tLock       *sync.Mutex\n\tMap        map[string]*WaveshellProc // key=remoteid\n\tCmdWaitMap map[base.CommandKey][]func()\n}\n```\n\n```go\nvar GlobalStore *Store\n```\n\n```go\ntype UserInputCancelError struct {\n\tErr error\n}\n```\n\n```go\nfunc (uice UserInputCancelError) Error() string\n```\n\n```go\ntype WaveshellProc struct {\n\tLock   *sync.Mutex\n\tRemote *sstore.RemoteType\n\n\t// runtime\n\tRemoteId           string // can be read without a lock\n\tStatus             string\n\tServerProc         *shexec.ClientProc // the server process\n\tUName              string\n\tErr                error\n\tErrNoInitPk        bool\n\tControllingPty     *os.File\n\tPtyBuffer          *circbuf.Buffer\n\tMakeClientCancelFn context.CancelFunc\n\tMakeClientDeadline *time.Time\n\tStateMap           *server.ShellStateMap\n\tNumTryConnect      int\n\tInitPkShellType    string\n\tDataPosMap         *utilfn.SyncMap[base.CommandKey, int64]\n\n\t// install\n\tInstallStatus         string\n\tNeedsWaveshellUpgrade bool\n\tInstallCancelFn       context.CancelFunc\n\tInstallErr            error\n\n\t// for synthetic commands (not run through RunCommand), this provides a way for them\n\t// to register to receive input events from the frontend (e.g. ReInit)\n\tCommandInputMap map[base.CommandKey]CommandInputSink\n\n\tRunningCmds      map[base.CommandKey]*RunCmdType\n\tPendingStateCmds map[pendingStateKey]base.CommandKey // key=[remoteinstance name] (in progress commands that might update the state)\n\n\tClient *ssh.Client\n\t// contains filtered or unexported fields\n}\n```\nprovides state, acccess, and control for a waveshell server process\n\n```go\nfunc GetLocalRemote() *WaveshellProc\n```\n\n```go\nfunc GetRemoteByArg(arg string) *WaveshellProc\n```\n\n```go\nfunc GetRemoteById(remoteId string) *WaveshellProc\n```\n\n```go\nfunc MakeWaveshell(r *sstore.RemoteType) *WaveshellProc\n```\n\n```go\nfunc (wsh *WaveshellProc) AddRunningCmd(rct *RunCmdType)\n```\n\n```go\nfunc (wsh *WaveshellProc) CancelInstall()\n```\n\n```go\nfunc (wsh *WaveshellProc) ChangeSudoTimeout(deltaTime int64)\n```\n\n```go\nfunc (wsh *WaveshellProc) CheckPasswordRequested(ctx context.Context, requiresPassword chan bool)\n```\n\n```go\nfunc (wsh *WaveshellProc) ClearCachedSudoPw()\n```\n\n```go\nfunc (wsh *WaveshellProc) Disconnect(force bool)\n```\n\n```go\nfunc (wsh *WaveshellProc) GetDisplayName() string\n```\n\n```go\nfunc (wsh *WaveshellProc) GetInstallStatus() string\n```\n\n```go\nfunc (wsh *WaveshellProc) GetNumRunningCommands() int\n```\n\n```go\nfunc (wsh *WaveshellProc) GetRemoteCopy() sstore.RemoteType\n```\n\n```go\nfunc (wsh *WaveshellProc) GetRemoteId() string\n```\n\n```go\nfunc (wsh *WaveshellProc) GetRemoteName() string\n```\n\n```go\nfunc (wsh *WaveshellProc) GetRemoteRuntimeState() RemoteRuntimeState\n```\n\n```go\nfunc (wsh *WaveshellProc) GetRunningCmd(ck base.CommandKey) *RunCmdType\n```\n\n```go\nfunc (wsh *WaveshellProc) GetShellPref() string\n```\nif wsh.IsConnected() then GetShellPref() should return a valid shell if wsh is not connected, then InitPkShellType might be empty\n\n```go\nfunc (wsh *WaveshellProc) GetShellType() string\n```\n\n```go\nfunc (wsh *WaveshellProc) GetStatus() string\n```\n\n```go\nfunc (wsh *WaveshellProc) GetUName() string\n```\n\n```go\nfunc (wsh *WaveshellProc) HandleFeInput(inputPk *scpacket.FeInputPacketType) error\n```\n\n```go\nfunc (wsh *WaveshellProc) IsCmdRunning(ck base.CommandKey) bool\n```\n\n```go\nfunc (wsh *WaveshellProc) IsConnected() bool\n```\n\n```go\nfunc (wsh *WaveshellProc) IsLocal() bool\n```\n\n```go\nfunc (wsh *WaveshellProc) IsSudo() bool\n```\n\n```go\nfunc (wsh *WaveshellProc) KillRunningCommandAndWait(ctx context.Context, ck base.CommandKey) error\n```\n\n```go\nfunc (wsh *WaveshellProc) Launch(interactive bool)\n```\n\n```go\nfunc (wsh *WaveshellProc) NotifyRemoteUpdate()\n```\n\n```go\nfunc (wsh *WaveshellProc) PacketRpc(ctx context.Context, pk packet.RpcPacketType) (*packet.ResponsePacketType, error)\n```\n\n```go\nfunc (wsh *WaveshellProc) PacketRpcIter(ctx context.Context, pk packet.RpcPacketType) (*packet.RpcResponseIter, error)\n```\n\n```go\nfunc (wsh *WaveshellProc) PacketRpcRaw(ctx context.Context, pk packet.RpcPacketType) (packet.RpcResponsePacketType, error)\n```\n\n```go\nfunc (wsh *WaveshellProc) ProcessPackets()\n```\n\n```go\nfunc (wsh *WaveshellProc) ReInit(ctx context.Context, ck base.CommandKey, shellType string, dataFn func([]byte), verbose bool) (rtnPk *packet.ShellStatePacketType, rtnErr error)\n```\n\n```go\nfunc (wsh *WaveshellProc) RemoveRunningCmd(ck base.CommandKey)\n```\n\n```go\nfunc (wsh *WaveshellProc) ResetDataPos(ck base.CommandKey)\n```\n\n```go\nfunc (wsh *WaveshellProc) RunInstall(autoInstall bool)\n```\n\n```go\nfunc (wsh *WaveshellProc) RunPasswordReadLoop(cmdPty *os.File)\n```\n\n```go\nfunc (wsh *WaveshellProc) RunPtyReadLoop(cmdPty *os.File)\n```\n\n```go\nfunc (wsh *WaveshellProc) SendFileData(dataPk *packet.FileDataPacketType) error\n```\n\n```go\nfunc (wsh *WaveshellProc) SendPassword(pw string)\n```\n\n```go\nfunc (wsh *WaveshellProc) StreamFile(ctx context.Context, streamPk *packet.StreamFilePacketType) (*packet.RpcResponseIter, error)\n```\n\n```go\nfunc (wsh *WaveshellProc) TryAutoConnect() error\n```\n\n```go\nfunc (wsh *WaveshellProc) UpdateRemote(ctx context.Context, editMap map[string]interface{}) error\n```\n\n```go\nfunc (wsh *WaveshellProc) WaitAndSendPassword(pw string)\n```\n\n```go\nfunc (wsh *WaveshellProc) WaitAndSendPasswordNew(pw string)\n```\n\n```go\nfunc (wsh *WaveshellProc) WithLock(fn func())\n```\n\n```go\nfunc (wsh *WaveshellProc) WriteFile(ctx context.Context, writePk *packet.WriteFilePacketType) (*packet.RpcResponseIter, error)\n```\n\n```go\nfunc (wsh *WaveshellProc) WriteToPtyBuffer(strFmt string, args ...interface{})\n```\n\n","path":"github.com/wavetermdev/waveterm/wavesrv/pkg/remote","name":"remote","synopsis":"","isRedistributable":true}
