feat: binarios pre-compilados del agente + endpoint de descarga
- Cross-compila usite-agent para linux/amd64, linux/arm64, linux/arm Binarios en agent/dist/ (CGO_ENABLED=0, stripped ~6MB c/u) - GET /agent/download/:filename sirve el binario correcto con Content-Disposition attachment y validación anti path-traversal - install.sh ya apunta a /agent/download/usite-agent-linux-ARCH Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot
parent
d9d3f8a5eb
commit
c3f19991c9
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user