remote

package
v0.7.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2024 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusConnected    = sstore.RemoteStatus_Connected
	StatusConnecting   = sstore.RemoteStatus_Connecting
	StatusDisconnected = sstore.RemoteStatus_Disconnected
	StatusError        = sstore.RemoteStatus_Error
)
View Source
const CircBufSize = 64 * 1024
View Source
const DefaultMaxPtySize = 1024 * 1024
View Source
const DefaultTerm = "xterm-256color"
View Source
const MaxInputDataSize = 1000
View Source
const NewStateDiffSizeThreshold = 30 * 1024

after this limit we'll switch to persisting the full state

View Source
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

View Source
const PtyReadBufSize = 100
View Source
const RemoteConnectTimeout = 15 * time.Second
View Source
const RemoteTermCols = 80
View Source
const RemoteTermRows = 8
View Source
const RemoteTypeWaveshell = "mshell"
View Source
const RpcIterChannelSize = 100
View Source
const SudoTimeoutTime = 5 * time.Minute
View Source
const WaveshellServerCommandFmt = `` /* 252-byte string literal not displayed */

Variables

This section is empty.

Functions

func AddRemote

func AddRemote(ctx context.Context, r *sstore.RemoteType, shouldStart bool) error

func ArchiveRemote

func ArchiveRemote(ctx context.Context, remoteId string) error

func CanComplete

func CanComplete(remoteType string) bool

func ConnectToClient

func ConnectToClient(connCtx context.Context, opts *sstore.SSHOpts, remoteDisplayName string) (*ssh.Client, error)

func DialContext

func DialContext(ctx context.Context, network string, addr string, config *ssh.ClientConfig) (*ssh.Client, error)

func EvalPrompt

func EvalPrompt(promptFmt string, vars map[string]string, state *packet.ShellState) string

func GetRemoteCopyById

func GetRemoteCopyById(remoteId string) *sstore.RemoteType

func GetRemoteMap

func GetRemoteMap() map[string]*WaveshellProc

func LoadRemoteById

func LoadRemoteById(ctx context.Context, remoteId string) error

func LoadRemotes

func LoadRemotes(ctx context.Context) error

func MakeLocalWaveshellCommandStr

func MakeLocalWaveshellCommandStr(isSudo bool) (string, error)

func MakeServerCommandStr

func MakeServerCommandStr() string

func NumRemotes

func NumRemotes() int

func ReadRemotePty

func ReadRemotePty(ctx context.Context, remoteId string) (int64, []byte, error)

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

func SendSignalToCmd

func SendSignalToCmd(ctx context.Context, cmd *sstore.CmdType, sig string) error

Types

type CircleLog

type CircleLog struct {
	Lock     *sync.Mutex
	StartPos int
	Log      []string
	MaxSize  int
}

func MakeCircleLog

func MakeCircleLog(maxSize int) *CircleLog

func (*CircleLog) Add

func (l *CircleLog) Add(s string)

func (*CircleLog) Addf

func (l *CircleLog) Addf(sfmt string, args ...interface{})

func (*CircleLog) GetEntries

func (l *CircleLog) GetEntries() []string

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 SshKeywords struct {
	User                         string
	HostName                     string
	Port                         string
	IdentityFile                 []string
	BatchMode                    bool
	PubkeyAuthentication         bool
	PasswordAuthentication       bool
	KbdInteractiveAuthentication bool
	PreferredAuthentications     []string
}

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 (*WaveshellProc) PacketRpcIter

func (wsh *WaveshellProc) PacketRpcIter(ctx context.Context, pk packet.RpcPacketType) (*packet.RpcResponseIter, error)

func (*WaveshellProc) PacketRpcRaw

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 (*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 (*WaveshellProc) WriteToPtyBuffer

func (wsh *WaveshellProc) WriteToPtyBuffer(strFmt string, args ...interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL