Add tactical fleet remote actions and agent command channel.
Extend remote commands with exec, PowerShell, file transfer, and fleet-wide broadcast; refresh AgentRemoteActions UI and WebSocket handling.
This commit is contained in:
@@ -81,6 +81,9 @@ func (f *FleetHandler) GetAgentLog(w http.ResponseWriter, r *http.Request) {
|
||||
type agentCommandRequest struct {
|
||||
Action string `json:"action"`
|
||||
TailLines int `json:"tail_lines,omitempty"`
|
||||
Command string `json:"command,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
Data string `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func (f *FleetHandler) PostAgentCommand(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -102,9 +105,23 @@ func (f *FleetHandler) PostAgentCommand(w http.ResponseWriter, r *http.Request)
|
||||
if req.TailLines > 0 {
|
||||
args["tail_lines"] = req.TailLines
|
||||
}
|
||||
if err := f.ws.SendAgentCommand(id, req.Action, args); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
if req.Command != "" {
|
||||
args["command"] = req.Command
|
||||
}
|
||||
if req.Path != "" {
|
||||
args["path"] = req.Path
|
||||
}
|
||||
if req.Data != "" {
|
||||
args["data"] = req.Data
|
||||
}
|
||||
|
||||
if id == "all" {
|
||||
f.ws.BroadcastAgentCommand(req.Action, args)
|
||||
} else {
|
||||
if err := f.ws.SendAgentCommand(id, req.Action, args); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
}
|
||||
writeJSON(w, map[string]interface{}{
|
||||
"success": true,
|
||||
|
||||
Reference in New Issue
Block a user