msg

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSG_TERMINAL_DATA = iota
	MSG_TERMINAL_RESIZE
)

Variables

This section is empty.

Functions

func ReadCommand

func ReadCommand(conn net.Conn) (byte, error)

func ReadMessage

func ReadMessage(conn net.Conn, v interface{}) error

func ReadMessageWithTimeout added in v0.23.0

func ReadMessageWithTimeout(conn net.Conn, v interface{}, timeout time.Duration) error

func ReadRegistrationReply added in v0.33.0

func ReadRegistrationReply(conn net.Conn) (*RegisterChallenge, *RegisterResponse, error)

ReadRegistrationReply reads the next message after a Register and returns whichever arrives: a RegisterChallenge from a key-checking server, or the final RegisterResponse — including one sent directly by a pre-handshake server during a rolling upgrade. The two are told apart by their shape (a challenge carries ServerNonce and no Success).

func SendAddPortForward added in v0.24.0

func SendAddPortForward(conn net.Conn, entry model.PortForwardEntry) error

func SendEvent added in v0.28.0

func SendEvent(conn net.Conn, event *Event) error

func SendLogMessage added in v0.11.5

func SendLogMessage(conn net.Conn, message *LogMessage) error

func SendPeerIntroduce added in v0.31.0

func SendPeerIntroduce(conn net.Conn, intro *PeerIntroduce) error

SendPeerIntroduce writes a PeerIntroduce message on the given stream.

func SendRemovePortForward added in v0.24.0

func SendRemovePortForward(conn net.Conn, localPort uint16) error

func SendSSHAuthResult added in v0.33.0

func SendSSHAuthResult(conn net.Conn, result *SSHAuthResultMessage) error

func SendSpaceGetVar added in v0.21.0

func SendSpaceGetVar(conn net.Conn, name string) (string, error)

func SendSpaceNote added in v0.18.0

func SendSpaceNote(conn net.Conn, note string) error

func SendSpaceRestart added in v0.18.0

func SendSpaceRestart(conn net.Conn) error

func SendSpaceStop added in v0.18.0

func SendSpaceStop(conn net.Conn) error

func SendSpaceVar added in v0.21.0

func SendSpaceVar(conn net.Conn, name, value string) error

func SendUpdateJobs added in v0.33.0

func SendUpdateJobs(conn net.Conn, jobs []model.SpaceJob, enabled bool) error

SendUpdateJobs pushes new job definitions to the agent. Fire-and-forget: the agent applies the push without replying, and the definitions are re-sent in the registration response if the connection was down.

func WriteCommand

func WriteCommand(conn net.Conn, cmdType CmdType) error

func WriteMessage

func WriteMessage(conn net.Conn, payload interface{}) error

Types

type AddPortForwardMsg added in v0.24.0

type AddPortForwardMsg struct {
	model.PortForwardEntry
}

type AgentState

type AgentState struct {
	HasCodeServer           bool
	SSHPort                 int
	VNCHttpPort             int
	HasTerminal             bool
	TcpPorts                map[string]string
	HttpPorts               map[string]string
	HasVSCodeTunnel         bool
	VSCodeTunnelName        string
	Healthy                 bool
	CPUPercent              float64
	MemoryUsedBytes         uint64
	MemoryLimitBytes        uint64
	DiskUsedBytes           uint64
	DiskLimitBytes          uint64
	ActivityWriteCount      uint32
	ActivityCreateCount     uint32
	ActivityDeleteCount     uint32
	ActivityRenameCount     uint32
	ActivityDistinctPaths   uint32
	ActivityBucketStartUnix int64
	ActivityBucketFinalized bool
	LastActivityAtUnix      int64
	MethodCallsTotal        uint64
	HTTPRequestsTotal       uint64
	TCPConnectionsTotal     uint64
}

type AgentStateReply added in v0.18.0

type AgentStateReply struct {
	Endpoints []string
}

func SendState

func SendState(conn net.Conn, hasCodeServer bool, sshPort int, vncHttpPort int, hasTerminal bool, tcpPorts *map[string]string, httpPorts *map[string]string, hasVSCodeTunnel bool, vscodeTunnelName string, healthy bool, cpuPercent float64, memoryUsedBytes uint64, memoryLimitBytes uint64, diskUsedBytes uint64, diskLimitBytes uint64, activityWriteCount uint32, activityCreateCount uint32, activityDeleteCount uint32, activityRenameCount uint32, activityDistinctPaths uint32, activityBucketStartUnix int64, activityBucketFinalized bool, lastActivityAtUnix int64, methodCallsTotal uint64, httpRequestsTotal uint64, tcpConnectionsTotal uint64) (AgentStateReply, error)

type CallMethodBatchItem added in v0.28.0

type CallMethodBatchItem struct {
	Method         string          `json:"method" msgpack:"method"`
	Params         json.RawMessage `json:"params,omitempty" msgpack:"params,omitempty"`
	ID             any             `json:"id,omitempty" msgpack:"id,omitempty"`
	IsNotification bool            `json:"-" msgpack:"is_notification,omitempty"`
}

CallMethodBatchItem is one call inside a batch sent from the knot server to the agent. The server has already routed and rewritten Method to local_name.

type CallMethodBatchRequest added in v0.28.0

type CallMethodBatchRequest struct {
	Items []CallMethodBatchItem `json:"items" msgpack:"items"`
}

CallMethodBatchRequest carries a sub-batch of calls targeting the same agent/space. The server groups incoming batch items by destination space and sends each group as one CallMethodBatchRequest over a single yamux stream.

type CallMethodBatchResponse added in v0.28.0

type CallMethodBatchResponse struct {
	Responses []methods.JSONRPCResponse `json:"responses" msgpack:"responses"`
}

CallMethodBatchResponse is the agent's reply to a batch. Responses are in the same order as the request items that had IDs. Notifications produce no response entry.

type CallMethodRequest added in v0.28.0

type CallMethodRequest struct {
	Method         string          `json:"method" msgpack:"method"`
	Params         json.RawMessage `json:"params,omitempty" msgpack:"params,omitempty"`
	ID             any             `json:"id,omitempty" msgpack:"id,omitempty"`
	IsNotification bool            `json:"-" msgpack:"is_notification,omitempty"`
}

type CallMethodResponse added in v0.28.0

type CallMethodResponse struct {
	Response methods.JSONRPCResponse `json:"response" msgpack:"response"`
}

type CmdType added in v0.11.5

type CmdType byte
const (
	CmdNone CmdType = iota
	CmdPing
	CmdUpdateState
	CmdUpdateAuthorizedKeys
	CmdTerminal
	CmdCodeServer
	CmdProxyTCPPort
	CmdProxyVNC
	CmdProxyHTTP
	CmdVSCodeTunnelTerminal
	CmdLogMessage
	CmdUpdateShell
	CmdUpdateSpaceNote
	CmdUpdateSpaceVar
	CmdGetSpaceVar
	CmdTunnelPort
	CmdTunnelPortConnection
	CmdSpaceStop
	CmdSpaceRestart
	CmdRunCommand
	CmdCopyFile
	CmdPortForward
	CmdPortList
	CmdPortStop
	CmdExecuteScript
	CmdExecuteScriptStream
	CmdAddPortForward
	CmdRemovePortForward
	CmdRegisterMethods
	CmdCallMethod
	CmdCallMethodBatch
	CmdUnregisterMethods
	CmdUpdateHealthConfig
	CmdEvent
	CmdTunnelStart
	CmdTunnelStop
	CmdTunnelList
	CmdGrep
	CmdFind
	CmdSed
	CmdEditFile
	CmdDeleteFile
	CmdPeerIntroduce
	CmdPeerRequestIntro
	CmdThrottlePort
	CmdPortForwardNotify
	CmdMirrorLog
	CmdSSHPortAuthResult
	CmdScriptLibsChanged
	CmdJobsList
	CmdJobsRun
	CmdUpdateJobs
)

type CopyFileMessage added in v0.19.0

type CopyFileMessage struct {
	SourcePath    string `msgpack:"source_path"`
	DestPath      string `msgpack:"dest_path"`
	Content       []byte `msgpack:"content,omitempty"`
	Direction     string `msgpack:"direction"` // "to_space" or "from_space"
	Workdir       string `msgpack:"workdir"`
	Mode          string `msgpack:"mode,omitempty"`           // to_space only: "overwrite" (default), "append", "prepend"
	MtimeNs       int64  `msgpack:"mtime_ns,omitempty"`       // to_space only: unix nanoseconds; agent Chtimes after write
	FilePerm      uint32 `msgpack:"file_perm,omitempty"`      // to_space only: os.FileMode bits; agent Chmod after write
	SymlinkTarget string `msgpack:"symlink_target,omitempty"` // to_space only: when set, create symlink instead of writing content
}

CopyFileMessage is the agent-side payload for a single file copy in either direction (to_space / from_space).

Mode is the write semantics for to_space: "overwrite" (default), "append", or "prepend".

MtimeNs and FilePerm are optional to_space metadata used by sync tools to preserve the source file's modification time and permission bits — both are applied AFTER the content write so the file ends up byte-identical to the source. Zero values mean "leave alone".

type CopyFileResponse added in v0.19.0

type CopyFileResponse struct {
	Success bool   `msgpack:"success"`
	Error   string `msgpack:"error"`
	Content []byte `msgpack:"content,omitempty"`
}

type DeleteFileMessage added in v0.31.0

type DeleteFileMessage struct {
	Path      string `msgpack:"path" json:"path"`
	Recursive bool   `msgpack:"recursive,omitempty" json:"recursive,omitempty"`
	Workdir   string `msgpack:"workdir,omitempty" json:"workdir,omitempty"`
}

DeleteFileMessage removes a file or directory from the space's agent. Recursive is required to delete a non-empty directory (matches os.RemoveAll semantics); a non-recursive delete on a non-empty directory fails. Missing paths are treated as success so the call is idempotent.

type DeleteFileResponse added in v0.31.0

type DeleteFileResponse struct {
	Success bool   `msgpack:"success" json:"success"`
	Error   string `msgpack:"error,omitempty" json:"error,omitempty"`
	Removed int    `msgpack:"removed,omitempty" json:"removed,omitempty"`
}

DeleteFileResponse is the agent's reply to a DeleteFileMessage. Removed is the number of filesystem entries removed (1 for a single file; for a recursive delete it counts the tree). Missing paths return Success=true with Removed=0 so callers can be idempotent.

type EditFileMessage added in v0.30.0

type EditFileMessage struct {
	Path    string `msgpack:"path" json:"path"`
	Search  string `msgpack:"search" json:"search"`
	Replace string `msgpack:"replace" json:"replace"`
	Workdir string `msgpack:"workdir,omitempty" json:"workdir,omitempty"`
}

EditFileMessage performs a targeted search-and-replace on a single file in the space's agent via the scriptling extlibs EditFile function. The search text must appear exactly once (uniqueness check); the modification is written atomically (temp file + rename).

type EditFileResponse added in v0.30.0

type EditFileResponse struct {
	Success      bool   `msgpack:"success" json:"success"`
	Error        string `msgpack:"error,omitempty" json:"error,omitempty"`
	BytesWritten int    `msgpack:"bytes_written,omitempty" json:"bytes_written,omitempty"`
}

type Event added in v0.28.0

type Event struct {
	EventId   string
	EventType string
	SpaceId   string
	UserId    string
	Payload   []byte
}

type EventReply added in v0.28.0

type EventReply struct{}

type ExecuteScriptMessage added in v0.23.0

type ExecuteScriptMessage struct {
	Content      string   `msgpack:"content"`
	Arguments    []string `msgpack:"arguments"`
	IsSystemCall bool     `msgpack:"is_system_call"`
}

type ExecuteScriptResponse added in v0.23.0

type ExecuteScriptResponse struct {
	Success  bool   `msgpack:"success"`
	Error    string `msgpack:"error"`
	Output   string `msgpack:"output"`
	ExitCode int    `msgpack:"exit_code"`
}

type ExecuteScriptStreamMessage added in v0.23.0

type ExecuteScriptStreamMessage struct {
	Content   string   `msgpack:"content"`
	Arguments []string `msgpack:"arguments"`
}

type ExtractMatch added in v0.30.0

type ExtractMatch struct {
	File   string   `msgpack:"file" json:"file"`
	Line   int      `msgpack:"line" json:"line"`
	Text   string   `msgpack:"text" json:"text"`
	Groups []string `msgpack:"groups,omitempty" json:"groups,omitempty"`
}

ExtractMatch is a single match with capture groups (for extract mode).

type FindEntry added in v0.31.0

type FindEntry struct {
	Path       string  `msgpack:"path" json:"path"`
	Size       int64   `msgpack:"size" json:"size"`
	Mtime      float64 `msgpack:"mtime" json:"mtime"` // epoch seconds
	IsDir      bool    `msgpack:"is_dir" json:"is_dir"`
	Hash       uint64  `msgpack:"hash,omitempty" json:"hash,omitempty"`
	LinkTarget string  `msgpack:"link_target,omitempty" json:"link_target,omitempty"`
	FilePerm   int     `msgpack:"file_perm,omitempty" json:"file_perm,omitempty"`
}

FindEntry is a single matching file or directory, carrying the metadata callers need to decide whether the entry has changed without re-reading the bytes. Only populated when FindMessage.IncludeMetadata is set; the default response shape uses Paths instead (no per-entry stat cost). Hash is crc64-ISO of file content, populated when IncludeHash is set.

type FindMessage added in v0.30.0

type FindMessage struct {
	Path            string   `msgpack:"path" json:"path"`
	Recursive       bool     `msgpack:"recursive" json:"recursive"`
	Type            string   `msgpack:"type,omitempty" json:"type,omitempty"` // "any", "file", "dir"
	Name            string   `msgpack:"name,omitempty" json:"name,omitempty"`
	IncludeHidden   bool     `msgpack:"include_hidden" json:"include_hidden"`
	IncludeMetadata bool     `msgpack:"include_metadata,omitempty" json:"include_metadata,omitempty"`
	IncludeHash     bool     `msgpack:"include_hash,omitempty" json:"include_hash,omitempty"`
	IncludeSymlinks bool     `msgpack:"include_symlinks,omitempty" json:"include_symlinks,omitempty"`
	FollowLinks     bool     `msgpack:"follow_links" json:"follow_links"`
	MaxDepth        int      `msgpack:"max_depth,omitempty" json:"max_depth,omitempty"`
	MtimeMin        *float64 `msgpack:"mtime_min,omitempty" json:"mtime_min,omitempty"`
	MtimeMax        *float64 `msgpack:"mtime_max,omitempty" json:"mtime_max,omitempty"`
	SizeMin         *int64   `msgpack:"size_min,omitempty" json:"size_min,omitempty"`
	SizeMax         *int64   `msgpack:"size_max,omitempty" json:"size_max,omitempty"`
	Workdir         string   `msgpack:"workdir,omitempty" json:"workdir,omitempty"`
}

FindMessage finds files/directories in the space's agent via the scriptling extlibs Find function (concurrent walker).

By default the response carries only Paths (cheap — no per-entry stat when size/mtime filters are inactive). Set IncludeMetadata=true to get Entries with size, mtime, and is_dir per match — the agent stats every match in that mode, so only opt in when you actually need the metadata (e.g. for differential sync).

type FindResponse added in v0.30.0

type FindResponse struct {
	Success bool        `msgpack:"success" json:"success"`
	Error   string      `msgpack:"error,omitempty" json:"error,omitempty"`
	Paths   []string    `msgpack:"paths,omitempty" json:"paths,omitempty"`
	Entries []FindEntry `msgpack:"entries,omitempty" json:"entries,omitempty"`
}

FindResponse is the agent's reply to a FindMessage.

INVARIANT: exactly one of Paths or Entries is populated per response, never both, never neither (on success). The agent picks based on FindMessage.IncludeMetadata:

  • IncludeMetadata=false (default) → Paths is populated. Cheap — the underlying walker returns matching path strings without stat'ing each entry (unless size/mtime filters force it).
  • IncludeMetadata=true → Entries is populated. Every matching entry is stat'd; only opt in when you actually need size/mtime/is_dir.

Callers that read both fields are wrong; pick one based on the request flag.

type GrepMatch added in v0.30.0

type GrepMatch struct {
	File string `msgpack:"file" json:"file"`
	Line int    `msgpack:"line" json:"line"`
	Text string `msgpack:"text" json:"text"`
}

GrepMatch is a single matching line.

type GrepMessage added in v0.30.0

type GrepMessage struct {
	Pattern     string `msgpack:"pattern" json:"pattern"`
	Path        string `msgpack:"path" json:"path"`
	Literal     bool   `msgpack:"literal" json:"literal"`
	Recursive   bool   `msgpack:"recursive" json:"recursive"`
	IgnoreCase  bool   `msgpack:"ignore_case" json:"ignore_case"`
	Glob        string `msgpack:"glob,omitempty" json:"glob,omitempty"`
	FollowLinks bool   `msgpack:"follow_links" json:"follow_links"`
	MaxSize     int64  `msgpack:"max_size,omitempty" json:"max_size,omitempty"`
	Workdir     string `msgpack:"workdir,omitempty" json:"workdir,omitempty"`
}

GrepMessage searches file contents in the space's agent via the scriptling extlibs Grep function (parallel worker pool, no interpreter).

type GrepResponse added in v0.30.0

type GrepResponse struct {
	Success bool        `msgpack:"success" json:"success"`
	Error   string      `msgpack:"error,omitempty" json:"error,omitempty"`
	Matches []GrepMatch `msgpack:"matches,omitempty" json:"matches,omitempty"`
}

type HealthConfig added in v0.28.0

type HealthConfig struct {
	HealthCheckType          string
	HealthCheckConfig        string
	HealthCheckSkipSSLVerify bool
	HealthCheckTimeout       uint32
	HealthCheckInterval      uint32
	HealthCheckMaxFailures   uint32
	HealthCheckAutoRestart   bool
}

type HttpPort

type HttpPort struct {
	Port       uint16
	ServerName string
}

type JobsResponse added in v0.33.0

type JobsResponse struct {
	Success bool   `json:"success" msgpack:"success"`
	Error   string `json:"error,omitempty" msgpack:"error,omitempty"`
}

JobsResponse is the outcome of a run request.

type JobsRunMessage added in v0.33.0

type JobsRunMessage struct {
	Name string `json:"name" msgpack:"name"`
}

JobsRunMessage asks the agent to start a job immediately by name. Sent from the server to the agent.

type LogLevel added in v0.11.5

type LogLevel byte
const (
	LogLevelDebug LogLevel = iota
	LogLevelInfo
	LogLevelError
)

type LogMessage added in v0.11.5

type LogMessage struct {
	Level   LogLevel
	Service string
	Message string
	Date    time.Time

	// Fields carries optional structured key/values from structured ingest
	// formats (e.g. VictoriaLogs jsonline) through to log sinks and space
	// log forwarding. Nil for unstructured sources.
	Fields map[string]string `msgpack:"fields"`
}

type MirrorLogEntry added in v0.33.0

type MirrorLogEntry struct {
	SpaceId   string            `msgpack:"space_id"`
	SpaceName string            `msgpack:"space_name"`
	User      string            `msgpack:"user"` // owner of the source space
	Service   string            `msgpack:"service"`
	Level     LogLevel          `msgpack:"level"`
	Message   string            `msgpack:"message"`
	Date      time.Time         `msgpack:"date"`
	Fields    map[string]string `msgpack:"fields,omitempty"`
}

MirrorLogEntry is a single log record mirrored to a log sink space, tagged with the space it came from. Service is the single selector, matching the agent's in-space ingest and the external logger: the space's service name for space records, or "tunnel" for tunnel records.

type MirrorLogMessage added in v0.33.0

type MirrorLogMessage struct {
	Entries []*MirrorLogEntry `msgpack:"entries"`
}

MirrorLogMessage is a batch of log records sent from the server to a space registered as a log sink. The sink space's agent forwards the entries to the local log service on the port it advertised at registration, in the format it requested (vl | loki | gelf | json).

type PeerAuth added in v0.31.0

type PeerAuth struct {
	Response []byte `msgpack:"response"`
}

PeerAuth is the dialer's response to a PeerChallenge: HMAC-SHA256 of the nonce keyed by the zone-wide agentToken.

type PeerAuthResult added in v0.31.0

type PeerAuthResult struct {
	Success bool   `msgpack:"success"`
	Error   string `msgpack:"error,omitempty"`
}

PeerAuthResult tells the dialer whether authentication succeeded.

type PeerChallenge added in v0.31.0

type PeerChallenge struct {
	Nonce []byte `msgpack:"nonce"`
}

PeerChallenge is sent by the listening agent. It contains a random nonce that the dialer must HMAC with the shared zone agentToken.

type PeerConnect added in v0.31.0

type PeerConnect struct {
	SourceSpaceId string `msgpack:"source_space_id"`
}

PeerConnect is the first message a dialing agent sends on a direct peer-to-peer connection. It identifies who is calling.

type PeerEndpoint added in v0.31.0

type PeerEndpoint struct {
	Host string
	Port uint16
}

PeerEndpoint is a dialable address for a peer agent's direct listener.

type PeerIntroduce added in v0.31.0

type PeerIntroduce struct {
	TargetSpace   string `msgpack:"target_space"`    // space name (matches PortForwardRequest.Space)
	TargetSpaceId string `msgpack:"target_space_id"` // space ID (for logging)
	Host          string `msgpack:"host"`
	Port          uint16 `msgpack:"port"`
}

PeerIntroduce is sent from the server to an agent to tell it the address of another agent it can connect to directly. The agent should attempt a direct connection to the given address; if it fails, it falls back to relay via the server.

type PeerRequestIntro added in v0.31.0

type PeerRequestIntro struct {
	Space string `msgpack:"space"`
}

PeerRequestIntro is sent from an agent to the server when a direct connection fails and the agent suspects the stored endpoint is stale (e.g. the target space restarted with a new port). The server resolves the target's current address and responds with a PeerIntroduce.

type Pong

type Pong struct {
	Payload string
}

type PortForwardInfo added in v0.22.2

type PortForwardInfo struct {
	LocalPort   uint16 `json:"local_port" msgpack:"local_port"`
	Space       string `json:"space" msgpack:"space"`
	RemotePort  uint16 `json:"remote_port" msgpack:"remote_port"`
	Persistent  bool   `json:"persistent" msgpack:"persistent"`
	Mode        string `json:"mode" msgpack:"mode"` // "relay" or "direct"
	LatencyMs   int    `json:"latency_ms" msgpack:"latency_ms"`
	JitterMs    int    `json:"jitter_ms" msgpack:"jitter_ms"`
	BandwidthKB int    `json:"bandwidth_kb" msgpack:"bandwidth_kb"`
	TimeoutMs   int    `json:"timeout_ms" msgpack:"timeout_ms"`
	Down        bool   `json:"down" msgpack:"down"`
}

type PortForwardRequest added in v0.22.2

type PortForwardRequest struct {
	LocalPort  uint16 `json:"local_port" msgpack:"local_port"`
	Space      string `json:"space" msgpack:"space"`
	RemotePort uint16 `json:"remote_port" msgpack:"remote_port"`
	Persistent bool   `json:"persistent" msgpack:"persistent"`
	Force      bool   `json:"force" msgpack:"force"`
}

Port forward between spaces

type PortForwardResponse added in v0.22.2

type PortForwardResponse struct {
	Success bool   `json:"success" msgpack:"success"`
	Error   string `json:"error" msgpack:"error"`
}

type PortListResponse added in v0.22.2

type PortListResponse struct {
	Forwards []PortForwardInfo `json:"forwards" msgpack:"forwards"`
}

type PortStopRequest added in v0.22.2

type PortStopRequest struct {
	LocalPort uint16 `json:"local_port" msgpack:"local_port"`
}

type PortStopResponse added in v0.22.2

type PortStopResponse struct {
	Success bool   `json:"success" msgpack:"success"`
	Error   string `json:"error" msgpack:"error"`
}

type Register

type Register struct {
	SpaceId  string
	Version  string
	PeerPort uint16 // external port peers should dial for direct connections (0 = no direct)

	// Registration handshake: Nonce starts the challenge; Proof answers the
	// server's RegisterChallenge with HMAC(registrationKey, spaceId|nonce|serverNonce).
	// Both empty = pre-handshake agent.
	Nonce string
	Proof string

	// Log sink registration (0 = not a sink). When set, the space asks to
	// receive a mirror of the log records of the spaces owned by the same
	// user, delivered as CmdMirrorLog batches that the agent writes to this
	// local port in this format (vl | loki | gelf | json).
	LogSinkPort   int
	LogSinkFormat string
}

message sent from an agent to the server to register itself

type RegisterChallenge added in v0.33.0

type RegisterChallenge struct {
	ServerNonce string
}

message sent from the server to an agent whose Register carried a nonce: the agent must reply with a Register whose Proof is computed over both nonces, proving possession of the space's registration key without ever sending it.

type RegisterMethodsRequest added in v0.28.0

type RegisterMethodsRequest struct {
	Registration methods.Registration `json:"registration" msgpack:"registration"`
}

type RegisterMethodsResponse added in v0.28.0

type RegisterMethodsResponse struct {
	Success bool   `json:"success" msgpack:"success"`
	Error   string `json:"error,omitempty" msgpack:"error,omitempty"`
}

type RegisterResponse

type RegisterResponse struct {
	Version                  string
	Success                  bool
	Error                    string // failure reason when Success is false
	SSHKeys                  []string
	SSHPrivateKey            string
	GitHubUsernames          []string
	Shell                    string
	SSHHostSigner            string
	WithTerminal             bool
	WithVSCodeTunnel         bool
	WithCodeServer           bool
	WithSSH                  bool
	WithRunCommand           bool
	Freeze                   bool
	AgentToken               string
	ServerURL                string
	AgentEndpoint            string
	HealthCheckType          string
	HealthCheckConfig        string
	HealthCheckSkipSSLVerify bool
	HealthCheckTimeout       uint32
	HealthCheckInterval      uint32
	HealthCheckMaxFailures   uint32
	HealthCheckAutoRestart   bool
	PortForwards             []model.PortForwardEntry
	Jobs                     []model.SpaceJob
	JobsEnabled              bool
	DirectEnabled            bool   // if true, server supports direct agent-to-agent connections
	PeerSecret               string // zone-wide shared secret for direct peer auth
}

message sent from the server to the agent in response to a register message

type RemovePortForwardMsg added in v0.24.0

type RemovePortForwardMsg struct {
	LocalPort uint16 `json:"local_port" msgpack:"local_port"`
}

type RunCommandMessage added in v0.19.0

type RunCommandMessage struct {
	Command string   `msgpack:"command"`
	Args    []string `msgpack:"args"`
	Timeout int      `msgpack:"timeout"`
	Workdir string   `msgpack:"workdir"`
}

type RunCommandResponse added in v0.19.0

type RunCommandResponse struct {
	Success bool   `msgpack:"success"`
	Error   string `msgpack:"error"`
	Output  []byte `msgpack:"output"`
}

type SSHAuthResultMessage added in v0.33.0

type SSHAuthResultMessage struct {
	Success        bool
	KeyFingerprint string
	RemoteAddr     string
	When           time.Time
}

SSHAuthResultMessage reports a public-key authentication attempt against the agent's SSH server: the outcome, the key's SHA256 fingerprint and the client address. Sent agent to server; the server records it under server.audit.space_sessions.

type ScriptLibsChanged added in v0.33.0

type ScriptLibsChanged struct {
	UserId string `json:"user_id,omitempty"`
}

ScriptLibsChanged notifies agents that a `lib`-type script changed on the server so they can drop their cached libs.zip package. UserId is set for a user library change (delivery targeted at that user's space agents) and empty for a global library change (broadcast to every agent).

type SedMessage added in v0.30.0

type SedMessage struct {
	Mode        string `msgpack:"mode" json:"mode"` // "replace", "replace_pattern", "extract"
	Pattern     string `msgpack:"pattern" json:"pattern"`
	Replacement string `msgpack:"replacement,omitempty" json:"replacement,omitempty"`
	Path        string `msgpack:"path" json:"path"`
	Recursive   bool   `msgpack:"recursive" json:"recursive"`
	IgnoreCase  bool   `msgpack:"ignore_case" json:"ignore_case"`
	Glob        string `msgpack:"glob,omitempty" json:"glob,omitempty"`
	FollowLinks bool   `msgpack:"follow_links" json:"follow_links"`
	MaxSize     int64  `msgpack:"max_size,omitempty" json:"max_size,omitempty"`
	Workdir     string `msgpack:"workdir,omitempty" json:"workdir,omitempty"`
}

SedMessage performs an in-place edit or capture extraction in the space's agent via the scriptling extlibs Sed functions. Mode selects the operation: "replace" (literal), "replace_pattern" (regex), or "extract" (read-only capture-group extraction).

type SedResponse added in v0.30.0

type SedResponse struct {
	Success       bool           `msgpack:"success" json:"success"`
	Error         string         `msgpack:"error,omitempty" json:"error,omitempty"`
	Mode          string         `msgpack:"mode,omitempty" json:"mode,omitempty"`
	FilesModified int64          `msgpack:"files_modified,omitempty" json:"files_modified,omitempty"` // replace / replace_pattern
	Matches       []ExtractMatch `msgpack:"matches,omitempty" json:"matches,omitempty"`               // extract
}

type SpaceGetVar added in v0.21.0

type SpaceGetVar struct {
	Name string
}

type SpaceGetVarResponse added in v0.21.0

type SpaceGetVarResponse struct {
	Value string
}

type SpaceNote added in v0.18.0

type SpaceNote struct {
	Note string
}

type SpaceVar added in v0.21.0

type SpaceVar struct {
	Name  string
	Value string
}

type TcpPort

type TcpPort struct {
	Port uint16
}

type Terminal

type Terminal struct {
	Shell string
}

message for terminal

type TerminalWindowSize

type TerminalWindowSize struct {
	Rows uint16 `json:"rows"`
	Cols uint16 `json:"cols"`
	X    uint16
	Y    uint16
}

type ThrottlePortRequest added in v0.31.0

type ThrottlePortRequest struct {
	LocalPort   uint16 `json:"local_port" msgpack:"local_port"`
	LatencyMs   int    `json:"latency_ms" msgpack:"latency_ms"`
	JitterMs    int    `json:"jitter_ms" msgpack:"jitter_ms"`
	BandwidthKB int    `json:"bandwidth_kb" msgpack:"bandwidth_kb"`
	TimeoutMs   int    `json:"timeout_ms" msgpack:"timeout_ms"`
	Down        bool   `json:"down" msgpack:"down"`
	Reset       bool   `json:"reset" msgpack:"reset"`
}

ThrottlePortRequest configures latency, jitter, and bandwidth limits on an existing port forward. Sent from the server to the agent.

type ThrottlePortResponse added in v0.31.0

type ThrottlePortResponse struct {
	Success bool   `json:"success" msgpack:"success"`
	Error   string `json:"error" msgpack:"error"`
}

type TunnelInfo added in v0.29.0

type TunnelInfo struct {
	Port     uint16 `json:"port" msgpack:"port"`
	Protocol string `json:"protocol" msgpack:"protocol"`
	Name     string `json:"name" msgpack:"name"`
	URL      string `json:"url" msgpack:"url"`
}

type TunnelListResponse added in v0.29.0

type TunnelListResponse struct {
	Tunnels []TunnelInfo `json:"tunnels" msgpack:"tunnels"`
}

type TunnelStartRequest added in v0.29.0

type TunnelStartRequest struct {
	Protocol      string `json:"protocol" msgpack:"protocol"`
	Port          uint16 `json:"port" msgpack:"port"`
	Name          string `json:"name" msgpack:"name"`
	TlsName       string `json:"tls_name,omitempty" msgpack:"tls_name,omitempty"`
	TlsSkipVerify bool   `json:"tls_skip_verify,omitempty" msgpack:"tls_skip_verify,omitempty"`
}

type TunnelStartResponse added in v0.29.0

type TunnelStartResponse struct {
	Success bool   `json:"success" msgpack:"success"`
	Error   string `json:"error,omitempty" msgpack:"error,omitempty"`
	URL     string `json:"url,omitempty" msgpack:"url,omitempty"`
}

func SendTunnelStart added in v0.29.0

func SendTunnelStart(conn net.Conn, req *TunnelStartRequest) (*TunnelStartResponse, error)

type TunnelStopRequest added in v0.29.0

type TunnelStopRequest struct {
	Name string `json:"name" msgpack:"name"`
}

type TunnelStopResponse added in v0.29.0

type TunnelStopResponse struct {
	Success bool   `json:"success" msgpack:"success"`
	Error   string `json:"error,omitempty" msgpack:"error,omitempty"`
}

type UpdateAuthorizedKeys

type UpdateAuthorizedKeys struct {
	SSHKeys         []string
	SSHPrivateKey   string
	GitHubUsernames []string
}

message sent to update the authorized keys within an agent

type UpdateJobsMessage added in v0.33.0

type UpdateJobsMessage struct {
	Jobs    []model.SpaceJob `json:"jobs" msgpack:"jobs"`
	Enabled bool             `json:"enabled" msgpack:"enabled"`
}

UpdateJobsMessage replaces the agent's in-memory job definitions and runner state with the space's persisted definitions. Sent from the server to the agent on every change; the registration response carries the same data on (re)connect.

type UpdateShell added in v0.11.5

type UpdateShell struct {
	Shell string
}

message sent to update the authorized keys within an agent

Jump to

Keyboard shortcuts

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