Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct {
ID string `json:"id"`
Shell string `json:"shell"`
Line string `json:"line"`
User string `json:"user"`
Group string `json:"group"`
Env map[string]string `json:"env"`
AllowSh bool `json:"allow_sh,omitempty"`
Data string `json:"data,omitempty"`
// Signature verification fields (populated by alpacon-server from AI server signing)
Signature string `json:"signature,omitempty"`
AnalyzedAt string `json:"analyzed_at,omitempty"`
KeyID string `json:"key_id,omitempty"`
}
Command represents a command request from the server
func (*Command) ParseCommandData ¶
func (c *Command) ParseCommandData() (*CommandData, error)
ParseCommandData parses the Data field of a Command into CommandData
type CommandChunk ¶ added in v2.3.1
CommandChunk represents one streamed chunk of a command's stdout/stderr.
type CommandData ¶
type CommandData struct {
SessionID string `json:"session_id"`
URL string `json:"url"`
Rows uint16 `json:"rows"`
Cols uint16 `json:"cols"`
Username string `json:"username"`
Groupname string `json:"groupname"`
Groupnames []string `json:"groupnames"`
HomeDirectory string `json:"home_directory"`
HomeDirectoryPermission string `json:"home_directory_permission"`
PurgeHomeDirectory bool `json:"purge_home"`
UID uint64 `json:"uid"`
GID uint64 `json:"gid"`
Comment string `json:"comment"`
Shell string `json:"shell"`
Groups []uint64 `json:"groups"`
IsServiceAccount bool `json:"is_service_account,omitempty"`
Type string `json:"type"`
Content string `json:"content"`
Path string `json:"path"`
Paths []string `json:"paths"`
Files []File `json:"files,omitempty"`
AllowOverwrite bool `json:"allow_overwrite,omitempty"`
AllowUnzip bool `json:"allow_unzip,omitempty"`
UseBlob bool `json:"use_blob,omitempty"`
Keys []string `json:"keys"`
ChainName string `json:"chain_name"`
Method string `json:"method"`
Chain string `json:"chain"`
Protocol string `json:"protocol"`
PortStart int `json:"port_start"`
PortEnd int `json:"port_end"`
DPorts []int `json:"dports"`
ICMPType string `json:"icmp_type"`
Source string `json:"source"`
Destination string `json:"destination"`
Target string `json:"target"`
Description string `json:"description"`
Priority int `json:"priority"`
RuleType string `json:"rule_type"`
Rules []map[string]interface{} `json:"rules"`
Operation string `json:"operation"`
RuleID string `json:"rule_id"`
OldRuleID string `json:"old_rule_id"`
AssignmentID string `json:"assignment_id"`
ServerID string `json:"server_id"`
ChainNames []string `json:"chain_names"`
// Backend information
Backend string `json:"backend"`
Table string `json:"table"`
Family string `json:"family"`
// Firewalld specific fields
Zone string `json:"zone"`
Service string `json:"service"`
FirewalldRuleType string `json:"firewalld_rule_type"`
// UFW specific fields
Direction string `json:"direction"`
Interface string `json:"interface"`
// Tunnel specific fields
TargetPort int `json:"target_port"`
ClientType string `json:"client_type"` // cli, web, editor
}
CommandData holds additional command parameters
func (*CommandData) ToArgs ¶
func (c *CommandData) ToArgs() *common.CommandArgs
ToArgs converts CommandData to CommandArgs for executor compatibility
type CommandResponse ¶
type CommandResponse struct {
Success bool `json:"success"`
Result string `json:"result"`
ElapsedTime float64 `json:"elapsed_time"`
ExitCode int `json:"exit_code"`
}
CommandResponse represents a command execution result
func NewCommandResponse ¶
func NewCommandResponse(success bool, result string, elapsed float64, exitCode int) *CommandResponse
NewCommandResponse creates a new command response
type File ¶
type File struct {
Username string `json:"username"`
Groupname string `json:"groupname"`
Type string `json:"type"`
Content string `json:"content"`
Path string `json:"path"`
AllowOverwrite bool `json:"allow_overwrite"`
AllowUnzip bool `json:"allow_unzip"`
URL string `json:"url"`
}
File represents a file in command data
type Message ¶
type Message struct {
Query MessageType `json:"query"`
Command *Command `json:"command,omitempty"`
Reason string `json:"reason,omitempty"`
Raw json.RawMessage `json:"-"` // Original raw message for debugging
}
Message is the base protocol message envelope received from the server
func ParseMessage ¶
ParseMessage parses a raw JSON message into a Message struct
type MessageType ¶
type MessageType string
MessageType defines the type of protocol message
const ( MessageTypeCommand MessageType = "command" MessageTypeQuit MessageType = "quit" MessageTypeReconnect MessageType = "reconnect" MessageTypePing MessageType = "ping" )
type PingResponse ¶
type PingResponse struct {
Query string `json:"query"`
Timestamp time.Time `json:"timestamp,omitempty"`
}
PingResponse represents a ping response
func NewPingResponse ¶
func NewPingResponse() *PingResponse
NewPingResponse creates a new ping response