Add fleet groups, agent screenshots, deploy guards, and Crucible polish.
This commit is contained in:
@@ -47,8 +47,8 @@ func checkDashboardWSToken(r *http.Request) bool {
|
||||
}
|
||||
|
||||
var upgrader = websocket.Upgrader{
|
||||
ReadBufferSize: 4096,
|
||||
WriteBufferSize: 4096,
|
||||
ReadBufferSize: 512 * 1024,
|
||||
WriteBufferSize: 512 * 1024,
|
||||
CheckOrigin: func(r *http.Request) bool {
|
||||
return true // Allow all origins for local use
|
||||
},
|
||||
@@ -246,6 +246,17 @@ func (h *WSHub) isAgentConnected(agentID string) bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
// writeAgentJSON sends a message to a connected agent using the per-connection
|
||||
// write mutex. All post-auth outbound JSON must use this — never conn.WriteJSON
|
||||
// from the read loop, or commands and new_job messages can corrupt each other.
|
||||
func (h *WSHub) writeAgentJSON(agentID string, msg Message) error {
|
||||
ac := h.getAgentConn(agentID)
|
||||
if ac == nil {
|
||||
return fmt.Errorf("agent %s not connected", agentID)
|
||||
}
|
||||
return ac.SendJSON(msg)
|
||||
}
|
||||
|
||||
func (h *WSHub) SetPoolManager(manager *pool.Manager, defaultCfg pool.Config) {
|
||||
h.mu.Lock()
|
||||
h.poolManager = manager
|
||||
@@ -826,12 +837,12 @@ func (h *WSHub) HandleAgentWS(w http.ResponseWriter, r *http.Request) {
|
||||
if proxy != nil {
|
||||
job := proxy.GetCurrentJob()
|
||||
if job != nil {
|
||||
conn.WriteJSON(Message{Type: "new_job", Payload: mustMarshal(job)})
|
||||
_ = h.writeAgentJSON(agentID, Message{Type: "new_job", Payload: mustMarshal(job)})
|
||||
} else {
|
||||
conn.WriteJSON(Message{Type: "new_job", Payload: mustMarshal(map[string]string{"error": "no job available — pool connecting"})})
|
||||
_ = h.writeAgentJSON(agentID, Message{Type: "new_job", Payload: mustMarshal(map[string]string{"error": "no job available — pool connecting"})})
|
||||
}
|
||||
} else {
|
||||
conn.WriteJSON(Message{Type: "new_job", Payload: mustMarshal(map[string]string{"error": "pool connecting — retry shortly"})})
|
||||
_ = h.writeAgentJSON(agentID, Message{Type: "new_job", Payload: mustMarshal(map[string]string{"error": "pool connecting — retry shortly"})})
|
||||
}
|
||||
|
||||
case "log_tail":
|
||||
@@ -899,6 +910,11 @@ func (h *WSHub) HandleDashboardWS(w http.ResponseWriter, r *http.Request) {
|
||||
// Send initial data
|
||||
agents, _ := h.db.ListAgents()
|
||||
h.enrichAgentsCapabilities(agents)
|
||||
for _, a := range agents {
|
||||
if a != nil && h.isAgentConnected(a.ID) {
|
||||
a.Status = "online"
|
||||
}
|
||||
}
|
||||
stats, _ := h.db.GetFleetStats()
|
||||
|
||||
_ = dc.WriteJSON(Message{Type: "init", Payload: mustMarshal(map[string]interface{}{
|
||||
|
||||
Reference in New Issue
Block a user