package hammerhead import ( "context" "net/http" "time" "git.veillax.com/Veillax/reef/selfupdate" ) // checkUpdate asks the release server whether a newer Hammerhead exists. It only looks: updating is // left to auto-update or to the person running the server. func (s *Server) checkUpdate(w http.ResponseWriter, r *http.Request, p *principal) { o := s.opts cfg := selfupdate.Config{Server: o.UpdateServer, Repo: o.UpdateRepo, App: "hammerhead", Current: o.Version} if cfg.Server == "" { cfg.Server = "https://git.veillax.com" } if cfg.Repo == "" { cfg.Repo = "Veillax/hammerhead" } ctx, cancel := context.WithTimeout(r.Context(), 20*time.Second) defer cancel() out := map[string]any{"current": o.Version, "autoUpdate": o.AutoUpdate, "checked": time.Now()} latest, newer, err := selfupdate.Check(ctx, cfg) out["latest"], out["newer"] = latest, newer if err != nil { out["error"] = err.Error() } writeJSON(w, 200, out) }