packet

package
v0.0.0-...-1234919 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 22 Imported by: 11

Documentation

Index

Constants

View Source
const (
	RunPacketStr            = "run" // rpc
	PingPacketStr           = "ping"
	InitPacketStr           = "init"
	DataPacketStr           = "data"     // command
	DataAckPacketStr        = "dataack"  // command
	CmdStartPacketStr       = "cmdstart" // rpc-response
	CmdDonePacketStr        = "cmddone"  // command
	DataEndPacketStr        = "dataend"
	ResponsePacketStr       = "resp" // rpc-response
	DonePacketStr           = "done"
	MessagePacketStr        = "message"
	GetCmdPacketStr         = "getcmd"    // rpc
	UntailCmdPacketStr      = "untailcmd" // rpc
	CdPacketStr             = "cd"        // rpc
	RawPacketStr            = "raw"
	SpecialInputPacketStr   = "sinput"         // command
	CompGenPacketStr        = "compgen"        // rpc
	ReInitPacketStr         = "reinit"         // rpc
	CmdFinalPacketStr       = "cmdfinal"       // command, pushed at the "end" of a command (fail-safe for no cmddone)
	StreamFilePacketStr     = "streamfile"     // rpc
	StreamFileResponseStr   = "streamfileresp" // rpc-response
	WriteFilePacketStr      = "writefile"      // rpc
	WriteFileReadyPacketStr = "writefileready" // rpc-response
	WriteFileDonePacketStr  = "writefiledone"  // rpc-response
	FileDataPacketStr       = "filedata"
	FileStatPacketStr       = "filestat"
	LogPacketStr            = "log" // logging packet (sent from waveshell back to server)
	ShellStatePacketStr     = "shellstate"
	RpcInputPacketStr       = "rpcinput" // rpc-followup
	SudoRequestPacketStr    = "sudorequest"
	SudoResponsePacketStr   = "sudoresponse"

	OpenAIPacketStr   = "openai" // other
	OpenAICloudReqStr = "openai-cloudreq"
)
View Source
const (
	ShellType_bash = "bash"
	ShellType_zsh  = "zsh"
)
View Source
const (
	EC_InvalidCwd    = "ERRCWD"
	EC_CmdNotRunning = "CMDNOTRUNNING"
)
View Source
const MaxCompGenValues = 100
View Source
const OpenAICmdInfoChatGreetingMessage = "" /* 192-byte string literal not displayed */
View Source
const PacketEOFStr = "EOF"
View Source
const PacketSenderQueueSize = 20
View Source
const ShellStateDiffPackVersion = 0
View Source
const ShellStatePackVersion = 0

Variables

View Source
var GlobalDebug = false
View Source
var TypeStrToFactory map[string]reflect.Type

Functions

func AsExtType

func AsExtType(pk PacketType) string

func AsString

func AsString(pk PacketType) string

func B64DecodedLen

func B64DecodedLen(b64 string) int

func GetMajorVersion

func GetMajorVersion(versionStr string) string

returns a string like "v4" ("" is an unparseable version)

func IsValidCompGenType

func IsValidCompGenType(t string) bool

func MarshalPacket

func MarshalPacket(packet PacketType) ([]byte, error)

func ParseShellStateVersion

func ParseShellStateVersion(fullVersionStr string) (string, string, error)

returns (shell, version, error)

func RegisterPacketType

func RegisterPacketType(typeStr string, rtype reflect.Type)

func SendPacket

func SendPacket(w io.Writer, packet PacketType) error

func StateVersionsCompatible

func StateVersionsCompatible(v1 string, v2 string) bool

we're going to allow different versions (as long as shelltype is the same) before we required version numbers to match exactly which was too restrictive

Types

type BarePacketType

type BarePacketType struct {
	Type string `json:"type"`
}

type CdPacketType

type CdPacketType struct {
	Type  string `json:"type"`
	ReqId string `json:"reqid"`
	Dir   string `json:"dir"`
}

func MakeCdPacket

func MakeCdPacket() *CdPacketType

func (*CdPacketType) GetReqId

func (p *CdPacketType) GetReqId() string

func (*CdPacketType) GetType

func (*CdPacketType) GetType() string

type CmdDonePacketType

type CmdDonePacketType struct {
	Type              string          `json:"type"`
	Ts                int64           `json:"ts"`
	CK                base.CommandKey `json:"ck"`
	ExitCode          int             `json:"exitcode"`
	DurationMs        int64           `json:"durationms"`
	FinalState        *ShellState     `json:"finalstate,omitempty"`
	FinalStateDiff    *ShellStateDiff `json:"finalstatediff,omitempty"`
	FinalStateBasePtr *ShellStatePtr  `json:"finalstatebaseptr,omitempty"`
}

func MakeCmdDonePacket

func MakeCmdDonePacket(ck base.CommandKey) *CmdDonePacketType

func (*CmdDonePacketType) GetCK

func (p *CmdDonePacketType) GetCK() base.CommandKey

func (*CmdDonePacketType) GetType

func (*CmdDonePacketType) GetType() string

type CmdFinalPacketType

type CmdFinalPacketType struct {
	Type  string          `json:"type"`
	Ts    int64           `json:"ts"`
	CK    base.CommandKey `json:"ck"`
	Error string          `json:"error"`
}

func MakeCmdFinalPacket

func MakeCmdFinalPacket(ck base.CommandKey) *CmdFinalPacketType

func (*CmdFinalPacketType) GetCK

func (pk *CmdFinalPacketType) GetCK() base.CommandKey

func (*CmdFinalPacketType) GetType

func (*CmdFinalPacketType) GetType() string

type CmdStartPacketType

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"`
	WaveshellPid int             `json:"waveshellpid,omitempty"`
}

func MakeCmdStartPacket

func MakeCmdStartPacket(reqId string) *CmdStartPacketType

func (*CmdStartPacketType) GetResponseDone

func (*CmdStartPacketType) GetResponseDone() bool

func (*CmdStartPacketType) GetResponseId

func (p *CmdStartPacketType) GetResponseId() string

func (*CmdStartPacketType) GetType

func (*CmdStartPacketType) GetType() string

type CommandPacketType

type CommandPacketType interface {
	GetType() string
	GetCK() base.CommandKey
}

type CompGenPacketType

type CompGenPacketType struct {
	Type     string `json:"type"`
	ReqId    string `json:"reqid"`
	Prefix   string `json:"prefix"`
	CompType string `json:"comptype"`
	Cwd      string `json:"cwd"`
}

func MakeCompGenPacket

func MakeCompGenPacket() *CompGenPacketType

func (*CompGenPacketType) GetReqId

func (p *CompGenPacketType) GetReqId() string

func (*CompGenPacketType) GetType

func (*CompGenPacketType) GetType() string

type DataAckPacketType

type DataAckPacketType struct {
	Type   string          `json:"type"`
	CK     base.CommandKey `json:"ck"`
	FdNum  int             `json:"fdnum"`
	AckLen int             `json:"acklen"`
	Error  string          `json:"error,omitempty"`
}

func MakeDataAckPacket

func MakeDataAckPacket() *DataAckPacketType

func (*DataAckPacketType) GetCK

func (p *DataAckPacketType) GetCK() base.CommandKey

func (*DataAckPacketType) GetType

func (*DataAckPacketType) GetType() string

func (*DataAckPacketType) String

func (p *DataAckPacketType) String() string

type DataEndPacketType

type DataEndPacketType struct {
	Type string          `json:"type"`
	CK   base.CommandKey `json:"ck"`
}

func MakeDataEndPacket

func MakeDataEndPacket(ck base.CommandKey) *DataEndPacketType

func (*DataEndPacketType) GetType

func (*DataEndPacketType) GetType() string

type DataPacketType

type DataPacketType struct {
	Type   string          `json:"type"`
	CK     base.CommandKey `json:"ck"`
	FdNum  int             `json:"fdnum"`
	Data64 string          `json:"data64"` // base64 encoded
	Eof    bool            `json:"eof,omitempty"`
	Error  string          `json:"error,omitempty"`
}

func MakeDataPacket

func MakeDataPacket() *DataPacketType

func (*DataPacketType) GetCK

func (p *DataPacketType) GetCK() base.CommandKey

func (*DataPacketType) GetType

func (*DataPacketType) GetType() string

func (*DataPacketType) String

func (p *DataPacketType) String() string

type DefaultUPR

type DefaultUPR struct{}

func (DefaultUPR) UnknownPacket

func (DefaultUPR) UnknownPacket(pk PacketType)

type DonePacketType

type DonePacketType struct {
	Type string `json:"type"`
}

func MakeDonePacket

func MakeDonePacket() *DonePacketType

func (*DonePacketType) GetType

func (*DonePacketType) GetType() string

type FileDataPacketType

type FileDataPacketType struct {
	Type   string `json:"type"`
	RespId string `json:"respid"`
	Data   []byte `json:"data"`
	Eof    bool   `json:"eof,omitempty"`
	Error  string `json:"error,omitempty"`
}

these packets can travel either direction so it is both a RpcResponsePacketType and an RpcFollowUpPacketType

func MakeFileDataPacket

func MakeFileDataPacket(reqId string) *FileDataPacketType

func (*FileDataPacketType) GetAssociatedReqId

func (p *FileDataPacketType) GetAssociatedReqId() string

func (*FileDataPacketType) GetResponseDone

func (p *FileDataPacketType) GetResponseDone() bool

func (*FileDataPacketType) GetResponseId

func (p *FileDataPacketType) GetResponseId() string

func (*FileDataPacketType) GetType

func (*FileDataPacketType) GetType() string

type FileInfo

type FileInfo struct {
	Name     string `json:"name"`
	Size     int64  `json:"size"`
	ModTs    int64  `json:"modts"`
	IsDir    bool   `json:"isdir,omitempty"`
	Perm     int    `json:"perm"`
	MimeType string `json:"mimetype,omitempty"`
	NotFound bool   `json:"notfound,omitempty"` // when NotFound is set, Perm will be set to permission for directory
}

type FileStatPacketType

type FileStatPacketType struct {
	Type    string    `json:"type"`
	Name    string    `json:"name"`
	Size    int64     `json:"size"`
	ModTs   time.Time `json:"modts"`
	IsDir   bool      `json:"isdir"`
	Perm    int       `json:"perm"`
	ModeStr string    `json:"modestr"`
	Error   string    `json:"error"`
	Done    bool      `json:"done"`
	RespId  string    `json:"respid"`
	Path    string    `json:"path"`
}

func MakeFileStatPacketFromFileInfo

func MakeFileStatPacketFromFileInfo(finfo fs.FileInfo, err string, done bool) *FileStatPacketType

func MakeFileStatPacketType

func MakeFileStatPacketType() *FileStatPacketType

func (*FileStatPacketType) GetResponseDone

func (p *FileStatPacketType) GetResponseDone() bool

func (*FileStatPacketType) GetResponseId

func (p *FileStatPacketType) GetResponseId() string

func (*FileStatPacketType) GetType

func (*FileStatPacketType) GetType() string

type GetCmdPacketType

type GetCmdPacketType struct {
	Type    string          `json:"type"`
	ReqId   string          `json:"reqid"`
	CK      base.CommandKey `json:"ck"`
	PtyPos  int64           `json:"ptypos"`
	RunPos  int64           `json:"runpos"`
	Tail    bool            `json:"tail,omitempty"`
	PtyOnly bool            `json:"ptyonly,omitempty"`
}

func MakeGetCmdPacket

func MakeGetCmdPacket() *GetCmdPacketType

func (*GetCmdPacketType) GetReqId

func (p *GetCmdPacketType) GetReqId() string

func (*GetCmdPacketType) GetType

func (*GetCmdPacketType) GetType() string

type InitPacketType

type InitPacketType struct {
	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 MakeInitPacket

func MakeInitPacket() *InitPacketType

func (*InitPacketType) GetResponseDone

func (pk *InitPacketType) GetResponseDone() bool

func (*InitPacketType) GetResponseId

func (pk *InitPacketType) GetResponseId() string

func (*InitPacketType) GetType

func (*InitPacketType) GetType() string

type LogPacketType

type LogPacketType struct {
	Type  string        `json:"type"`
	Entry wlog.LogEntry `json:"entry"`
}

func MakeLogPacket

func MakeLogPacket(entry wlog.LogEntry) *LogPacketType

func (*LogPacketType) GetType

func (*LogPacketType) GetType() string

func (*LogPacketType) String

func (p *LogPacketType) String() string

type MessagePacketType

type MessagePacketType struct {
	Type    string          `json:"type"`
	CK      base.CommandKey `json:"ck,omitempty"`
	Message string          `json:"message"`
}

func FmtMessagePacket

func FmtMessagePacket(fmtStr string, args ...interface{}) *MessagePacketType

func MakeMessagePacket

func MakeMessagePacket(message string) *MessagePacketType

func (*MessagePacketType) GetType

func (*MessagePacketType) GetType() string

func (*MessagePacketType) String

func (p *MessagePacketType) String() string

type MessageUPR

type MessageUPR struct {
	CK     base.CommandKey
	Sender *PacketSender
}

func (MessageUPR) UnknownPacket

func (upr MessageUPR) UnknownPacket(pk PacketType)

type ModelUpdatePacketType

type ModelUpdatePacketType struct {
	Type    string `json:"type"`
	Updates []any  `json:"updates"`
}

type OpenAICloudReqPacketType

type OpenAICloudReqPacketType struct {
	Type       string                    `json:"type"`
	ClientId   string                    `json:"clientid"`
	Prompt     []OpenAIPromptMessageType `json:"prompt"`
	MaxTokens  int                       `json:"maxtokens,omitempty"`
	MaxChoices int                       `json:"maxchoices,omitempty"`
}

func MakeOpenAICloudReqPacket

func MakeOpenAICloudReqPacket() *OpenAICloudReqPacketType

func (*OpenAICloudReqPacketType) GetType

func (*OpenAICloudReqPacketType) GetType() string

type OpenAICmdInfoChatMessage

type OpenAICmdInfoChatMessage struct {
	MessageID           int                            `json:"messageid"`
	IsAssistantResponse bool                           `json:"isassistantresponse,omitempty"`
	AssistantResponse   *OpenAICmdInfoPacketOutputType `json:"assistantresponse,omitempty"`
	UserQuery           string                         `json:"userquery,omitempty"`
	UserEngineeredQuery string                         `json:"userengineeredquery,omitempty"`
}

type OpenAICmdInfoPacketOutputType

type OpenAICmdInfoPacketOutputType struct {
	Model        string `json:"model,omitempty"`
	Created      int64  `json:"created,omitempty"`
	FinishReason string `json:"finish_reason,omitempty"`
	Message      string `json:"message,omitempty"`
	Error        string `json:"error,omitempty"`
}

type OpenAIPacketType

type OpenAIPacketType struct {
	Type         string           `json:"type"`
	Model        string           `json:"model,omitempty"`
	Created      int64            `json:"created,omitempty"`
	FinishReason string           `json:"finish_reason,omitempty"`
	Usage        *OpenAIUsageType `json:"usage,omitempty"`
	Index        int              `json:"index,omitempty"`
	Text         string           `json:"text,omitempty"`
	Error        string           `json:"error,omitempty"`
}

func MakeOpenAIPacket

func MakeOpenAIPacket() *OpenAIPacketType

func (*OpenAIPacketType) GetType

func (*OpenAIPacketType) GetType() string

type OpenAIPromptMessageType

type OpenAIPromptMessageType struct {
	Role    string `json:"role"`
	Content string `json:"content"`
	Name    string `json:"name,omitempty"`
}

type OpenAIUsageType

type OpenAIUsageType struct {
	PromptTokens     int `json:"prompt_tokens,omitempty"`
	CompletionTokens int `json:"completion_tokens,omitempty"`
	TotalTokens      int `json:"total_tokens,omitempty"`
}

type PacketParser

type PacketParser struct {
	Lock       *sync.Mutex
	MainCh     chan PacketType
	RpcMap     map[string]*RpcEntry
	RpcHandler bool
	Err        error
}

func CombinePacketParsers

func CombinePacketParsers(p1 *PacketParser, p2 *PacketParser, rpcHandler bool) *PacketParser

func MakePacketParser

func MakePacketParser(input io.Reader, opts *PacketParserOpts) *PacketParser

func (*PacketParser) GetErr

func (p *PacketParser) GetErr() error

func (*PacketParser) GetNextResponse

func (p *PacketParser) GetNextResponse(ctx context.Context, reqId string) (RpcResponsePacketType, error)

func (*PacketParser) GetResponseIter

func (p *PacketParser) GetResponseIter(reqId string) *RpcResponseIter

func (*PacketParser) RegisterRpc

func (p *PacketParser) RegisterRpc(reqId string) chan RpcResponsePacketType

func (*PacketParser) RegisterRpcSz

func (p *PacketParser) RegisterRpcSz(reqId string, queueSize int) chan RpcResponsePacketType

func (*PacketParser) SetErr

func (p *PacketParser) SetErr(err error)

func (*PacketParser) UnRegisterRpc

func (p *PacketParser) UnRegisterRpc(reqId string)

func (*PacketParser) WaitForResponse

func (p *PacketParser) WaitForResponse(ctx context.Context, reqId string) RpcResponsePacketType

should have already registered rpc

type PacketParserOpts

type PacketParserOpts struct {
	RpcHandler       bool
	IgnoreUntilValid bool
}

type PacketSender

type PacketSender struct {
	Lock       *sync.Mutex
	SendCh     chan PacketType
	Done       bool
	DoneCh     chan bool
	ErrHandler func(*PacketSender, PacketType, error)
	ExitErr    error
}

func MakeChannelPacketSender

func MakeChannelPacketSender(packetCh chan PacketType) *PacketSender

func MakePacketSender

func MakePacketSender(output io.Writer, errHandler func(*PacketSender, PacketType, error)) *PacketSender

func (*PacketSender) Close

func (sender *PacketSender) Close()

func (*PacketSender) SendErrorResponse

func (sender *PacketSender) SendErrorResponse(reqId string, err error) error

func (*PacketSender) SendLogPacket

func (sender *PacketSender) SendLogPacket(entry wlog.LogEntry)

func (*PacketSender) SendMessageFmt

func (sender *PacketSender) SendMessageFmt(fmtStr string, args ...interface{}) error

func (*PacketSender) SendPacket

func (sender *PacketSender) SendPacket(pk PacketType) error

func (*PacketSender) SendPacketCtx

func (sender *PacketSender) SendPacketCtx(ctx context.Context, pk PacketType) error

func (*PacketSender) SendResponse

func (sender *PacketSender) SendResponse(reqId string, data interface{}) error

func (*PacketSender) WaitForDone

func (sender *PacketSender) WaitForDone() error

returns ExitErr if set

type PacketType

type PacketType interface {
	GetType() string
}

func MakePacket

func MakePacket(packetType string) (PacketType, error)

func ParseJsonPacket

func ParseJsonPacket(jsonBuf []byte) (PacketType, error)

type PingPacketType

type PingPacketType struct {
	Type string `json:"type"`
}

func MakePingPacket

func MakePingPacket() *PingPacketType

func (*PingPacketType) GetType

func (*PingPacketType) GetType() string

type RawPacketType

type RawPacketType struct {
	Type string `json:"type"`
	Data string `json:"data"`
}

func MakeRawPacket

func MakeRawPacket(val string) *RawPacketType

func (*RawPacketType) GetType

func (*RawPacketType) GetType() string

func (*RawPacketType) String

func (p *RawPacketType) String() string

type ReInitPacketType

type ReInitPacketType struct {
	Type      string `json:"type"`
	ShellType string `json:"shelltype"`
	ReqId     string `json:"reqid"`
}

func MakeReInitPacket

func MakeReInitPacket() *ReInitPacketType

func (*ReInitPacketType) GetReqId

func (p *ReInitPacketType) GetReqId() string

func (*ReInitPacketType) GetType

func (*ReInitPacketType) GetType() string

type RemoteFd

type RemoteFd struct {
	FdNum    int  `json:"fdnum"`
	Read     bool `json:"read"`
	Write    bool `json:"write"`
	DupStdin bool `json:"-"`
}

type ResponsePacketType

type ResponsePacketType struct {
	Type      string      `json:"type"`
	RespId    string      `json:"respid"`
	Success   bool        `json:"success"`
	Error     string      `json:"error,omitempty"`
	ErrorCode string      `json:"errorcode,omitempty"` // can be used for structured errors
	Data      interface{} `json:"data,omitempty"`
}

func MakeErrorResponsePacket

func MakeErrorResponsePacket(reqId string, err error) *ResponsePacketType

func MakeResponsePacket

func MakeResponsePacket(reqId string, data interface{}) *ResponsePacketType

func (*ResponsePacketType) Err

func (p *ResponsePacketType) Err() error

func (*ResponsePacketType) GetResponseDone

func (*ResponsePacketType) GetResponseDone() bool

func (*ResponsePacketType) GetResponseId

func (p *ResponsePacketType) GetResponseId() string

func (*ResponsePacketType) GetType

func (*ResponsePacketType) GetType() string

func (*ResponsePacketType) String

func (p *ResponsePacketType) String() string

type RpcEntry

type RpcEntry struct {
	ReqId  string
	RespCh chan RpcResponsePacketType
}

type RpcFollowUpPacketType

type RpcFollowUpPacketType interface {
	GetType() string
	GetAssociatedReqId() string
}

RpcPackets initiate an Rpc. these can be part of the data passed back and forth

type RpcInputPacketType

type RpcInputPacketType struct {
	Type  string `json:"type"`
	ReqId string `json:"reqid"`
	Data  []byte `json:"data"`
}

func MakeRpcInputPacket

func MakeRpcInputPacket(reqId string) *RpcInputPacketType

func (*RpcInputPacketType) GetAssociatedReqId

func (p *RpcInputPacketType) GetAssociatedReqId() string

func (*RpcInputPacketType) GetType

func (*RpcInputPacketType) GetType() string

type RpcPacketType

type RpcPacketType interface {
	GetType() string
	GetReqId() string
}

type RpcResponseIter

type RpcResponseIter struct {
	ReqId  string
	Parser *PacketParser
}

func (*RpcResponseIter) Close

func (iter *RpcResponseIter) Close()

func (*RpcResponseIter) Next

type RpcResponsePacketType

type RpcResponsePacketType interface {
	GetType() string
	GetResponseId() string
	GetResponseDone() bool
}

type RunDataType

type RunDataType struct {
	FdNum   int    `json:"fdnum"`
	DataLen int    `json:"datalen"`
	Data    []byte `json:"-"`
}

type RunPacketBuilder

type RunPacketBuilder struct {
	RunMap map[base.CommandKey]*RunPacketType
}

todo: clean hanging entries in RunMap when in server mode

func MakeRunPacketBuilder

func MakeRunPacketBuilder() *RunPacketBuilder

func (*RunPacketBuilder) ProcessPacket

func (b *RunPacketBuilder) ProcessPacket(pk PacketType) (bool, *RunPacketType)

returns (consumed, fullRunPacket)

type RunPacketType

type RunPacketType struct {
	Type          string          `json:"type"`
	ReqId         string          `json:"reqid"`
	CK            base.CommandKey `json:"ck"`
	ShellType     string          `json:"shelltype"` // added in Wave v0.6.0 (either "bash" or "zsh") (set by remote.go)
	Command       string          `json:"command"`
	State         *ShellState     `json:"state,omitempty"`
	StatePtr      *ShellStatePtr  `json:"stateptr,omitempty"`      // added in Wave v0.7.2
	StateComplete bool            `json:"statecomplete,omitempty"` // set to true if state is complete (the default env should not be set)
	UsePty        bool            `json:"usepty,omitempty"`        // Set to true if the command should be run in a pty. This will write all output to the stdout file descriptor with PTY formatting.
	TermOpts      *TermOpts       `json:"termopts,omitempty"`
	Fds           []RemoteFd      `json:"fds,omitempty"`
	RunData       []RunDataType   `json:"rundata,omitempty"`
	Detached      bool            `json:"detached,omitempty"`
	ReturnState   bool            `json:"returnstate,omitempty"`
	IsSudo        bool            `json:"issudo,omitempty"`
	Timeout       time.Duration   `json:"timeout"` // TODO: added vnext. This is the timeout for the command to run.  If the command does not complete in this time, it will be killed. The default zero value will not impose a timeout.
}

func MakeRunPacket

func MakeRunPacket() *RunPacketType

func (*RunPacketType) GetReqId

func (p *RunPacketType) GetReqId() string

func (*RunPacketType) GetType

func (*RunPacketType) GetType() string

type SendError

type SendError struct {
	IsWriteError   bool // fatal
	IsMarshalError bool // not fatal
	PacketType     string
	Err            error
}

func (*SendError) Error

func (e *SendError) Error() string

func (*SendError) Unwrap

func (e *SendError) Unwrap() error

type ShellState

type ShellState struct {
	Version   string `json:"version"` // [type] [semver]
	Cwd       string `json:"cwd,omitempty"`
	ShellVars []byte `json:"shellvars,omitempty"`
	Aliases   string `json:"aliases,omitempty"`
	Funcs     string `json:"funcs,omitempty"`
	Error     string `json:"error,omitempty"`
	HashVal   string `json:"-"`
}

func (ShellState) ApproximateSize

func (state ShellState) ApproximateSize() int64

func (*ShellState) DecodeShellState

func (state *ShellState) DecodeShellState(barr []byte) error

func (ShellState) Dump

func (state ShellState) Dump()

func (ShellState) EncodeAndHash

func (state ShellState) EncodeAndHash() (string, []byte)

returns (SHA1, encoded-state)

func (*ShellState) GetHashVal

func (state *ShellState) GetHashVal(force bool) string

caches HashVal in struct

func (ShellState) GetLineDiffSplitString

func (state ShellState) GetLineDiffSplitString() string

func (ShellState) GetShellType

func (state ShellState) GetShellType() string

func (ShellState) IsEmpty

func (state ShellState) IsEmpty() bool

func (ShellState) MarshalJSON

func (state ShellState) MarshalJSON() ([]byte, error)

func (*ShellState) UnmarshalJSON

func (state *ShellState) UnmarshalJSON(jsonBytes []byte) error

type ShellStateDiff

type ShellStateDiff struct {
	Version     string   `json:"version"` // [type] [semver] (note this should *always* be set even if the same as base)
	BaseHash    string   `json:"basehash"`
	DiffHashArr []string `json:"diffhasharr,omitempty"`
	Cwd         string   `json:"cwd,omitempty"`
	VarsDiff    []byte   `json:"shellvarsdiff,omitempty"` // vardiff
	AliasesDiff []byte   `json:"aliasesdiff,omitempty"`   // linediff
	FuncsDiff   []byte   `json:"funcsdiff,omitempty"`     // linediff
	Error       string   `json:"error,omitempty"`
	HashVal     string   `json:"-"`
}

func (*ShellStateDiff) DecodeShellStateDiff

func (sdiff *ShellStateDiff) DecodeShellStateDiff(barr []byte) error

func (ShellStateDiff) Dump

func (sdiff ShellStateDiff) Dump(vars bool, aliases bool, funcs bool)

func (ShellStateDiff) EncodeAndHash

func (sdiff ShellStateDiff) EncodeAndHash() (string, []byte)

func (*ShellStateDiff) GetHashVal

func (sdiff *ShellStateDiff) GetHashVal(force bool) string

caches HashVal in struct

func (ShellStateDiff) GetShellType

func (diff ShellStateDiff) GetShellType() string

func (ShellStateDiff) MarshalJSON

func (sdiff ShellStateDiff) MarshalJSON() ([]byte, error)

func (*ShellStateDiff) UnmarshalJSON

func (sdiff *ShellStateDiff) UnmarshalJSON(jsonBytes []byte) error

type ShellStatePacketType

type ShellStatePacketType struct {
	Type      string           `json:"type"`
	ShellType string           `json:"shelltype"`
	RespId    string           `json:"respid,omitempty"`
	State     *ShellState      `json:"state"`
	Stats     *ShellStateStats `json:"stats"`
	Error     string           `json:"error,omitempty"`
}

func MakeShellStatePacket

func MakeShellStatePacket() *ShellStatePacketType

func (*ShellStatePacketType) GetResponseDone

func (p *ShellStatePacketType) GetResponseDone() bool

func (*ShellStatePacketType) GetResponseId

func (p *ShellStatePacketType) GetResponseId() string

func (*ShellStatePacketType) GetType

func (*ShellStatePacketType) GetType() string

func (*ShellStatePacketType) String

func (p *ShellStatePacketType) String() string

type ShellStatePtr

type ShellStatePtr struct {
	BaseHash    string   `json:"basehash"`
	DiffHashArr []string `json:"diffhasharr,omitempty"`
}

func (*ShellStatePtr) IsEmpty

func (ssptr *ShellStatePtr) IsEmpty() bool

type ShellStateStats

type ShellStateStats struct {
	Version    string `json:"version"`
	AliasCount int    `json:"aliascount"`
	EnvCount   int    `json:"envcount"`
	VarCount   int    `json:"varcount"`
	FuncCount  int    `json:"funccount"`
	HashVal    string `json:"hashval"`
	OutputSize int64  `json:"outputsize"`
	StateSize  int64  `json:"statesize"`
}

type SpecialInputPacketType

type SpecialInputPacketType struct {
	Type    string          `json:"type"`
	CK      base.CommandKey `json:"ck"`
	SigName string          `json:"signame,omitempty"` // passed to unix.SignalNum (needs 'SIG' prefix, e.g. "SIGTERM"), also accepts a number (e.g. "9")
	WinSize *WinSize        `json:"winsize,omitempty"`
}

SigNum gets sent to process via a signal WinSize, if set, will run TIOCSWINSZ to set size, and then send SIGWINCH

func MakeSpecialInputPacket

func MakeSpecialInputPacket() *SpecialInputPacketType

func (*SpecialInputPacketType) GetCK

func (*SpecialInputPacketType) GetType

func (*SpecialInputPacketType) GetType() string

type StreamFilePacketType

type StreamFilePacketType struct {
	Type      string  `json:"type"`
	ReqId     string  `json:"reqid"`
	Path      string  `json:"path"`
	ByteRange []int64 `json:"byterange"`          // works like the http "Range" header (multiple ranges are not allowed)
	StatOnly  bool    `json:"statonly,omitempty"` // set if you just want the stat response (no data returned)
}

func MakeStreamFilePacket

func MakeStreamFilePacket() *StreamFilePacketType

func (*StreamFilePacketType) GetReqId

func (p *StreamFilePacketType) GetReqId() string

func (*StreamFilePacketType) GetType

func (*StreamFilePacketType) GetType() string

type StreamFileResponseType

type StreamFileResponseType struct {
	Type   string    `json:"type"`
	RespId string    `json:"respid"`
	Done   bool      `json:"done,omitempty"`
	Info   *FileInfo `json:"info,omitempty"`
	Error  string    `json:"error,omitempty"`
}

func MakeStreamFileResponse

func MakeStreamFileResponse(respId string) *StreamFileResponseType

func (*StreamFileResponseType) GetResponseDone

func (p *StreamFileResponseType) GetResponseDone() bool

func (*StreamFileResponseType) GetResponseId

func (p *StreamFileResponseType) GetResponseId() string

func (*StreamFileResponseType) GetType

func (*StreamFileResponseType) GetType() string

type SudoRequestPacketType

type SudoRequestPacketType struct {
	Type        string          `json:"type"`
	CK          base.CommandKey `json:"ck"`
	ShellPubKey []byte          `json:"shellpubkey"`
	SudoStatus  string          `json:"sudostatus"`
	ErrStr      string          `json:"errstr"`
}

func MakeSudoRequestPacket

func MakeSudoRequestPacket(ck base.CommandKey, pubKey []byte, sudoStatus string) *SudoRequestPacketType

func (*SudoRequestPacketType) GetCK

func (*SudoRequestPacketType) GetType

func (*SudoRequestPacketType) GetType() string

type SudoResponsePacketType

type SudoResponsePacketType struct {
	Type      string          `json:"type"`
	CK        base.CommandKey `json:"ck"`
	Secret    []byte          `json:"secret"`
	SrvPubKey []byte          `json:"srvpubkey"`
}

func MakeSudoResponsePacket

func MakeSudoResponsePacket(ck base.CommandKey, secret []byte, srvPubKey []byte) *SudoResponsePacketType

func (*SudoResponsePacketType) GetCK

func (*SudoResponsePacketType) GetType

func (*SudoResponsePacketType) GetType() string

type TermOpts

type TermOpts struct {
	Rows       int    `json:"rows"`
	Cols       int    `json:"cols"`
	Term       string `json:"term"`
	MaxPtySize int64  `json:"maxptysize,omitempty"`
	FlexRows   bool   `json:"flexrows,omitempty"`
}

type UnknownPacketReporter

type UnknownPacketReporter interface {
	UnknownPacket(pk PacketType)
}

type UntailCmdPacketType

type UntailCmdPacketType struct {
	Type  string          `json:"type"`
	ReqId string          `json:"reqid"`
	CK    base.CommandKey `json:"ck"`
}

func MakeUntailCmdPacket

func MakeUntailCmdPacket() *UntailCmdPacketType

func (*UntailCmdPacketType) GetReqId

func (p *UntailCmdPacketType) GetReqId() string

func (*UntailCmdPacketType) GetType

func (*UntailCmdPacketType) GetType() string

type WinSize

type WinSize struct {
	Rows int `json:"rows"`
	Cols int `json:"cols"`
}

type WriteFileDonePacketType

type WriteFileDonePacketType struct {
	Type   string `json:"type"`
	RespId string `json:"reqid"`
	Error  string `json:"error,omitempty"`
}

func MakeWriteFileDonePacket

func MakeWriteFileDonePacket(reqId string) *WriteFileDonePacketType

func (*WriteFileDonePacketType) GetResponseDone

func (p *WriteFileDonePacketType) GetResponseDone() bool

func (*WriteFileDonePacketType) GetResponseId

func (p *WriteFileDonePacketType) GetResponseId() string

func (*WriteFileDonePacketType) GetType

func (*WriteFileDonePacketType) GetType() string

type WriteFilePacketType

type WriteFilePacketType struct {
	Type    string `json:"type"`
	ReqId   string `json:"reqid"`
	UseTemp bool   `json:"usetemp,omitempty"`
	Path    string `json:"path"`
}

func MakeWriteFilePacket

func MakeWriteFilePacket() *WriteFilePacketType

func (*WriteFilePacketType) GetReqId

func (p *WriteFilePacketType) GetReqId() string

func (*WriteFilePacketType) GetType

func (*WriteFilePacketType) GetType() string

type WriteFileReadyPacketType

type WriteFileReadyPacketType struct {
	Type   string `json:"type"`
	RespId string `json:"reqid"`
	Error  string `json:"error,omitempty"`
}

func MakeWriteFileReadyPacket

func MakeWriteFileReadyPacket(reqId string) *WriteFileReadyPacketType

func (*WriteFileReadyPacketType) GetResponseDone

func (p *WriteFileReadyPacketType) GetResponseDone() bool

func (*WriteFileReadyPacketType) GetResponseId

func (p *WriteFileReadyPacketType) GetResponseId() string

func (*WriteFileReadyPacketType) GetType

func (*WriteFileReadyPacketType) GetType() string

Jump to

Keyboard shortcuts

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