Documentation
¶
Overview ¶
Package protocol defines the WebSocket message types shared between the zeus agent and any compatible web server implementation. It has no internal dependencies and can be extracted into its own module.
Index ¶
Constants ¶
const ( TypeHello = "hello" TypeHeartbeat = "heartbeat" TypeCommand = "command" TypeStream = "stream" TypeResult = "result" TypeEvent = "event" TypePing = "ping" TypePong = "pong" )
Message types (Envelope.Type).
const ( CmdProfileNew = "profile.new" CmdProfileAdd = "profile.add" CmdProfileList = "profile.list" CmdProfileInfo = "profile.info" CmdProfileStart = "profile.start" CmdProfileStop = "profile.stop" CmdProfileRm = "profile.rm" CmdMissionsPull = "missions.pull" CmdUpdate = "update" )
Command names (Command.Cmd).
const ( EventProfileStarted = "profile.started" EventProfileStopped = "profile.stopped" )
Event names (Event.Event).
const ( FDStdout = "stdout" FDStderr = "stderr" )
FD labels for Stream messages.
const ( ScopeView = "view" // profile.list, profile.info (read-only) ScopeControl = "control" // profile.start, profile.stop ScopeManage = "manage" // profile.new, profile.add, profile.rm, missions.pull, profile.info (write operations) ScopeUpdate = "update" // update ScopeAll = "all" // no restrictions (default) )
Scope names for the --allow flag on zeus agent. Scopes restrict which commands the agent will accept and execute.
Variables ¶
var AllScopes = []string{ScopeView, ScopeControl, ScopeManage, ScopeUpdate}
AllScopes is the ordered list of all named scopes (excluding "all").
Functions ¶
func ResolveScopes ¶
ResolveScopes returns a set of allowed command names for the given scope list. Returns nil (allow everything) if scopes is empty or contains ScopeAll.
Types ¶
type Envelope ¶
type Envelope struct {
ID string `json:"id,omitempty"`
Type string `json:"type"`
Payload json.RawMessage `json:"payload"`
}
Envelope is the top-level wrapper for every message in both directions.
type Event ¶
type Event struct {
Event string `json:"event"`
Name string `json:"name,omitempty"`
PID int `json:"pid,omitempty"`
Reason string `json:"reason,omitempty"`
}
Event is the payload for TypeEvent messages (agent → server, spontaneous).
type Heartbeat ¶
type Heartbeat struct {
Agent string `json:"agent"`
ZeusVersion string `json:"zeus_version"`
Profiles []ProfileStatus `json:"profiles"`
AllowedScopes []string `json:"allowed_scopes,omitempty"` // nil/absent = all commands allowed
}
Heartbeat is the payload for TypeHeartbeat messages (agent → server, periodic).
type Hello ¶
type Hello struct {
Agent string `json:"agent"`
ZeusVersion string `json:"zeus_version"`
AllowedScopes []string `json:"allowed_scopes,omitempty"` // nil/absent = all commands allowed
}
Hello is the payload for TypeHello messages (agent → server, sent on connect).
type ProfileStatus ¶
type ProfileStatus struct {
Name string `json:"name"`
Running bool `json:"running"`
PID int `json:"pid,omitempty"`
}
ProfileStatus is the per-profile snapshot inside Heartbeat.