Documentation
¶
Overview ¶
Package agentproto defines the wire protocol between the ForgeVM host and the guest agent running inside Firecracker VMs. Messages are framed as 4-byte big-endian length prefix + JSON payload.
Index ¶
- Constants
- func MarshalParams(v any) (json.RawMessage, error)
- func MarshalResult(v any) (json.RawMessage, error)
- func ReadMessage(r io.Reader) ([]byte, error)
- func SendRequest(w io.Writer, req *Request) error
- func SendResponse(w io.Writer, resp *Response) error
- func SendStreamResponse(w io.Writer, resp *StreamResponse) error
- func UnmarshalParams(raw json.RawMessage, v any) error
- func UnmarshalResult(raw json.RawMessage, v any) error
- func WriteMessage(w io.Writer, v any) error
- type ChmodFileParams
- type DeleteFileParams
- type ExecParams
- type ExecResult
- type FileInfoResult
- type GlobFilesParams
- type GlobFilesResult
- type ListFilesParams
- type ListFilesResult
- type MoveFileParams
- type PingResult
- type ReadFileParams
- type ReadFileResult
- type Request
- type Response
- type StatFileParams
- type StreamResponse
- type WriteFileParams
Constants ¶
const ( MethodPing = "ping" MethodExec = "exec" MethodExecStream = "exec_stream" MethodWriteFile = "write_file" MethodReadFile = "read_file" MethodListFiles = "list_files" MethodDeleteFile = "delete_file" MethodMoveFile = "move_file" MethodChmodFile = "chmod_file" MethodStatFile = "stat_file" MethodGlobFiles = "glob_files" MethodShutdown = "shutdown" )
Method constants.
Variables ¶
This section is empty.
Functions ¶
func MarshalParams ¶
func MarshalParams(v any) (json.RawMessage, error)
MarshalParams marshals v into json.RawMessage for use in Request.Params.
func MarshalResult ¶
func MarshalResult(v any) (json.RawMessage, error)
MarshalResult marshals v into json.RawMessage for use in Response.Result.
func ReadMessage ¶
ReadMessage reads a length-prefixed message from r into buf.
func SendRequest ¶
SendRequest writes a Request to w.
func SendResponse ¶
SendResponse writes a Response to w.
func SendStreamResponse ¶
func SendStreamResponse(w io.Writer, resp *StreamResponse) error
SendStreamResponse writes a StreamResponse to w.
func UnmarshalParams ¶
func UnmarshalParams(raw json.RawMessage, v any) error
UnmarshalParams unmarshals Request.Params into v.
func UnmarshalResult ¶
func UnmarshalResult(raw json.RawMessage, v any) error
UnmarshalResult unmarshals Response.Result into v.
Types ¶
type ChmodFileParams ¶
ChmodFileParams are parameters for chmod_file.
type DeleteFileParams ¶
DeleteFileParams are parameters for delete_file.
type ExecParams ¶
type ExecParams struct {
Command string `json:"command"`
Args []string `json:"args,omitempty"`
WorkDir string `json:"work_dir,omitempty"`
Env map[string]string `json:"env,omitempty"`
}
ExecParams are parameters for exec and exec_stream methods.
type ExecResult ¶
type ExecResult struct {
ExitCode int `json:"exit_code"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
}
ExecResult is returned by the exec method.
type FileInfoResult ¶
type FileInfoResult struct {
Path string `json:"path"`
Size int64 `json:"size"`
Mode string `json:"mode"`
IsDir bool `json:"is_dir"`
ModTime string `json:"mod_time"`
}
FileInfoResult describes a single file entry.
type GlobFilesParams ¶
type GlobFilesParams struct {
Pattern string `json:"pattern"`
}
GlobFilesParams are parameters for glob_files.
type GlobFilesResult ¶
type GlobFilesResult struct {
Matches []string `json:"matches"`
}
GlobFilesResult is returned by glob_files.
type ListFilesParams ¶
type ListFilesParams struct {
Path string `json:"path"`
}
ListFilesParams are parameters for list_files.
type ListFilesResult ¶
type ListFilesResult struct {
Files []FileInfoResult `json:"files"`
}
ListFilesResult is returned by list_files.
type MoveFileParams ¶
MoveFileParams are parameters for move_file.
type PingResult ¶
type PingResult struct {
Pong bool `json:"pong"`
}
PingResult is returned by the ping method.
type ReadFileParams ¶
type ReadFileParams struct {
Path string `json:"path"`
}
ReadFileParams are parameters for read_file.
type ReadFileResult ¶
type ReadFileResult struct {
Content []byte `json:"content"`
}
ReadFileResult is returned by read_file.
type Request ¶
type Request struct {
ID string `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
Request is the envelope sent from host to agent.
type Response ¶
type Response struct {
ID string `json:"id"`
Error string `json:"error,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
}
Response is the envelope sent from agent to host for non-streaming methods.
type StatFileParams ¶
type StatFileParams struct {
Path string `json:"path"`
}
StatFileParams are parameters for stat_file.
type StreamResponse ¶
type StreamResponse struct {
ID string `json:"id"`
Stream string `json:"stream,omitempty"` // "stdout" or "stderr"
Data string `json:"data,omitempty"`
Error string `json:"error,omitempty"`
Done bool `json:"done,omitempty"`
ExitCode int `json:"exit_code,omitempty"`
}
StreamResponse is sent from agent to host for exec_stream, one per chunk.
func ReadStreamResponse ¶
func ReadStreamResponse(r io.Reader) (*StreamResponse, error)
ReadStreamResponse reads a StreamResponse from r.
type WriteFileParams ¶
type WriteFileParams struct {
Path string `json:"path"`
Content []byte `json:"content"`
Mode string `json:"mode,omitempty"`
}
WriteFileParams are parameters for write_file.