fix: Backend platform-aware Agent-Update (nicht mehr hardcoded freebsd)

This commit is contained in:
cynfo3000 2026-03-09 20:31:26 +01:00
parent 291d2e3c17
commit 358682e5f3

View File

@ -184,8 +184,20 @@ func (h *Handler) pushAgentUpdate(hub *ws.Hub) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
agentID := r.PathValue("id")
// TODO: Agent-Plattform aus DB lesen; fuer jetzt default freebsd
version, hash, binary, err := h.db.GetLatestFirmware("freebsd")
// Plattform aus Request-Body oder Query-Parameter lesen, default linux
platform := r.URL.Query().Get("platform")
if platform == "" {
var reqBody struct {
Platform string `json:"platform"`
}
body, _ := io.ReadAll(r.Body)
json.Unmarshal(body, &reqBody)
platform = reqBody.Platform
}
if platform == "" {
platform = "linux"
}
version, hash, binary, err := h.db.GetLatestFirmware(platform)
if err != nil {
writeError(w, http.StatusNotFound, "Keine Firmware verfuegbar")
return