diff --git a/rest/routes/publicas.go b/rest/routes/publicas.go index 76f54a3..4bfb814 100755 --- a/rest/routes/publicas.go +++ b/rest/routes/publicas.go @@ -43,6 +43,21 @@ func RutasPublicas(web fiber.Router) { c.Set("Content-Type", "text/plain; charset=utf-8") return c.SendFile("./agent/install.sh") }) + // Descargar binario pre-compilado del agente + // Ejemplo: GET /agent/download/usite-agent-linux-amd64 + web.Get("/agent/download/:filename", func(c *fiber.Ctx) error { + filename := c.Params("filename") + // Validar que sea un nombre de binario válido (sin path traversal) + for _, ch := range filename { + if ch == '/' || ch == '.' || ch == '\\' { + return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "nombre inválido"}) + } + } + path := "./agent/dist/" + filename + c.Set("Content-Disposition", "attachment; filename=\""+filename+"\"") + c.Set("Content-Type", "application/octet-stream") + return c.SendFile(path) + }) // ─── Página de estado del sistema (Atlassian Statuspage) ──────────────── web.Get("/status", controllers.StatusPage) }