|
|
|
@@ -370,7 +370,7 @@ func (s *Server) debugTestEvent(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
Severity string `json:"severity"`
|
|
|
|
|
}
|
|
|
|
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, "Érvénytelen kérés", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, s.msg(r, "debug.api.invalid_request"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if req.EventType == "" {
|
|
|
|
@@ -381,10 +381,13 @@ func (s *Server) debugTestEvent(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.notifier == nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, "Notifier nincs konfigurálva", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, s.msg(r, "debug.api.notifier_unconfigured"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// R-574: PAYLOAD, not page copy — this text travels to the hub as the test event's own message,
|
|
|
|
|
// so it stays a literal (every other Hungarian string in this file is debug-page copy and comes
|
|
|
|
|
// from the bundle, debug.api.*). The classification is written in TestR574_DebugPageCopyFollowsTheLanguage.
|
|
|
|
|
statusCode, err := s.notifier.PushTestEventSync(req.EventType, req.Severity,
|
|
|
|
|
fmt.Sprintf("Teszt esemény: %s (%s)", req.EventType, req.Severity))
|
|
|
|
|
if err != nil {
|
|
|
|
@@ -393,7 +396,7 @@ func (s *Server) debugTestEvent(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, fmt.Sprintf("Esemény elküldve (HTTP %d)", statusCode),
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, s.msg(r, "debug.api.event_sent", statusCode),
|
|
|
|
|
map[string]interface{}{"hub_status": statusCode})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -410,7 +413,7 @@ func (s *Server) debugEventHistory(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
|
|
|
|
func (s *Server) debugTriggerDBDump(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if s.backupMgr == nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, "Backup manager nincs konfigurálva", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, s.msg(r, "debug.api.backup_unconfigured"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
s.backupMgr.MarkManualRun() // R-182: a person pressed this, so its digest must not be collapsed
|
|
|
|
@@ -419,7 +422,7 @@ func (s *Server) debugTriggerDBDump(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
s.logger.Printf("[WARN] Debug DB dump failed: %v", err)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "DB dump elindítva", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, s.msg(r, "debug.api.db_dump_started"), nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// debugRunCrossDrive runs the Tier-2 (cross-drive) copy for every deployed HDD app (R-400).
|
|
|
|
@@ -435,14 +438,14 @@ func (s *Server) debugTriggerDBDump(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
// how a button reads as working while doing nothing — the class this whole row exists to close.
|
|
|
|
|
func (s *Server) debugRunCrossDrive(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if s.backupMgr == nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, "Backup manager nincs konfigurálva", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, s.msg(r, "debug.api.backup_unconfigured"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
names := crossDriveTargets(s.stackMgr.GetStacks(), func(name string) bool {
|
|
|
|
|
return s.backupMgr.Tier2Info(name).IsHDDApp
|
|
|
|
|
})
|
|
|
|
|
if len(names) == 0 {
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "Nincs olyan telepített alkalmazás, amelynek 2. mentése futtatható lenne",
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, s.msg(r, "debug.api.crossdrive_none"),
|
|
|
|
|
map[string]interface{}{"apps": names, "count": 0})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
@@ -456,7 +459,7 @@ func (s *Server) debugRunCrossDrive(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
}
|
|
|
|
|
}(names)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true,
|
|
|
|
|
fmt.Sprintf("Cross-drive mentés elindítva %d alkalmazásra", len(names)),
|
|
|
|
|
s.msg(r, "debug.api.crossdrive_started", len(names)),
|
|
|
|
|
map[string]interface{}{"apps": names, "count": len(names)})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -498,7 +501,7 @@ func crossDriveTargets(all []stacks.Stack, isHDDApp func(name string) bool) []st
|
|
|
|
|
// that would reintroduce the hazard.
|
|
|
|
|
func (s *Server) debugRunOffsiteProof(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if s.debugCallbacks == nil || s.debugCallbacks.RunOffsiteProof == nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusNotImplemented, false, "Nem bekötött", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusNotImplemented, false, s.msg(r, "debug.api.not_wired"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
res := s.debugCallbacks.RunOffsiteProof()
|
|
|
|
@@ -517,17 +520,17 @@ func (s *Server) debugRunOffsiteProof(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
case res.Skipped:
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "Kihagyva: "+res.SkipReason, data)
|
|
|
|
|
case res.NoSnapshot:
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "Nincs esedékes alkalmazás — minden legújabb mentés már ellenőrizve", data)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, s.msg(r, "debug.api.proof_none_due"), data)
|
|
|
|
|
case res.Err != nil:
|
|
|
|
|
// NOT a verdict about the backup: the restore did not finish, so nothing was concluded.
|
|
|
|
|
data["error"] = res.Err.Error()
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "A visszaállítás nem futott le — a mentésről semmi nem derült ki", data)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, s.msg(r, "debug.api.proof_not_run"), data)
|
|
|
|
|
case res.Judgement.Verdict == backup.UnitProofPass:
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "A mentés tartalmazza az alkalmazás adatait", data)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, s.msg(r, "debug.api.proof_ok"), data)
|
|
|
|
|
case res.Judgement.Verdict == backup.UnitProofCannotJudge:
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "Nem megítélhető — a mentés nem hordoz elég információt", data)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, s.msg(r, "debug.api.proof_unknown"), data)
|
|
|
|
|
default:
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, false, "A mentés olvasható, de nem tartalmazza az alkalmazás adatait", data)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, false, s.msg(r, "debug.api.proof_missing"), data)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -543,7 +546,7 @@ func (s *Server) debugRunOffsiteProof(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
// for it" is precisely the reasoning that would reintroduce the hazard.
|
|
|
|
|
func (s *Server) debugRunIntegrityCheck(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if s.debugCallbacks == nil || s.debugCallbacks.RunIntegrityCheck == nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusNotImplemented, false, "Nem bekötött", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusNotImplemented, false, s.msg(r, "debug.api.not_wired"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
res := s.debugCallbacks.RunIntegrityCheck(true)
|
|
|
|
@@ -563,11 +566,11 @@ func (s *Server) debugRunIntegrityCheck(w http.ResponseWriter, r *http.Request)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "Kihagyva: "+res.SkipReason, data)
|
|
|
|
|
case res.Unreachable:
|
|
|
|
|
// NOT reported as a failure: the store could not be opened, so nothing was concluded about it.
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "A tároló nem érhető el — az ellenőrzés nem futott le", data)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, s.msg(r, "debug.api.integrity_unreachable"), data)
|
|
|
|
|
case res.OK:
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "Az ellenőrzés rendben lezajlott", data)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, s.msg(r, "debug.api.integrity_ok"), data)
|
|
|
|
|
default:
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, false, "Az ellenőrzés hibát talált a tárolóban", data)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, false, s.msg(r, "debug.api.integrity_failed"), data)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -575,7 +578,7 @@ func (s *Server) debugRunIntegrityCheck(w http.ResponseWriter, r *http.Request)
|
|
|
|
|
|
|
|
|
|
func (s *Server) debugHubPush(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if s.debugCallbacks == nil || s.debugCallbacks.TriggerHubReportPush == nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusNotImplemented, false, "Nem bekötött", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusNotImplemented, false, s.msg(r, "debug.api.not_wired"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
start := time.Now()
|
|
|
|
@@ -585,13 +588,13 @@ func (s *Server) debugHubPush(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, false, s.errText(r, err), map[string]interface{}{"latency_ms": latency})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "Hub jelentés elküldve",
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, s.msg(r, "debug.api.hub_report_sent"),
|
|
|
|
|
map[string]interface{}{"latency_ms": latency})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *Server) debugHubConnectivity(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if s.debugCallbacks == nil || s.debugCallbacks.HubConnectivityTest == nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusNotImplemented, false, "Nem bekötött", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusNotImplemented, false, s.msg(r, "debug.api.not_wired"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
statusCode, latency, err := s.debugCallbacks.HubConnectivityTest()
|
|
|
|
@@ -604,12 +607,12 @@ func (s *Server) debugHubConnectivity(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true,
|
|
|
|
|
fmt.Sprintf("Hub elérhető (HTTP %d, %dms)", statusCode, latency), data)
|
|
|
|
|
s.msg(r, "debug.api.hub_reachable", statusCode, latency), data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *Server) debugPreferencesSync(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if s.notifier == nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, "Notifier nincs konfigurálva", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, s.msg(r, "debug.api.notifier_unconfigured"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
prefs := s.settings.GetNotificationPrefs()
|
|
|
|
@@ -617,12 +620,12 @@ func (s *Server) debugPreferencesSync(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, false, s.errText(r, err), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "Preferenciák szinkronizálva", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, s.msg(r, "debug.api.prefs_synced"), nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *Server) debugGiteaConnectivity(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if s.debugCallbacks == nil || s.debugCallbacks.GiteaConnectivityTest == nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusNotImplemented, false, "Nem bekötött", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusNotImplemented, false, s.msg(r, "debug.api.not_wired"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
statusCode, latency, err := s.debugCallbacks.GiteaConnectivityTest()
|
|
|
|
@@ -635,14 +638,14 @@ func (s *Server) debugGiteaConnectivity(w http.ResponseWriter, r *http.Request)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true,
|
|
|
|
|
fmt.Sprintf("Gitea elérhető (HTTP %d, %dms)", statusCode, latency), data)
|
|
|
|
|
s.msg(r, "debug.api.gitea_reachable", statusCode, latency), data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ── Section: Telemetry testing ───────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
func (s *Server) debugTelemetry(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if s.debugCallbacks == nil || s.debugCallbacks.GetTelemetryPreview == nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusNotImplemented, false, "Nem bekötött", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusNotImplemented, false, s.msg(r, "debug.api.not_wired"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
start := time.Now()
|
|
|
|
@@ -661,7 +664,7 @@ func (s *Server) debugTelemetry(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true,
|
|
|
|
|
fmt.Sprintf("Telemetria összegyűjtve: %d app, %d hiba, %d figyelmeztetés (%dms)",
|
|
|
|
|
s.msg(r, "debug.api.telemetry_collected",
|
|
|
|
|
len(telemetry), totalErrors, totalWarnings, latency),
|
|
|
|
|
map[string]interface{}{
|
|
|
|
|
"latency_ms": latency,
|
|
|
|
@@ -676,7 +679,7 @@ func (s *Server) debugTelemetry(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
|
|
|
|
func (s *Server) debugSelfUpdateDryRun(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if s.updater == nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, "Self-update nincs konfigurálva", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, s.msg(r, "debug.api.selfupdate_unconfigured"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
result := s.updater.DryRun()
|
|
|
|
@@ -690,11 +693,11 @@ func (s *Server) debugTriggerSetupWizard(w http.ResponseWriter, r *http.Request)
|
|
|
|
|
Confirm string `json:"confirm"`
|
|
|
|
|
}
|
|
|
|
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, "Érvénytelen kérés", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, s.msg(r, "debug.api.invalid_request"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if req.Confirm != "RESET" {
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, "Érvénytelen megerősítés — írja be: RESET", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusBadRequest, false, s.msg(r, "debug.api.reset_confirm_invalid"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -702,11 +705,11 @@ func (s *Server) debugTriggerSetupWizard(w http.ResponseWriter, r *http.Request)
|
|
|
|
|
markerPath := filepath.Join(s.cfg.Paths.DataDir, ".needs-setup")
|
|
|
|
|
if err := os.WriteFile(markerPath, []byte("debug-triggered\n"), 0644); err != nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusInternalServerError, false,
|
|
|
|
|
fmt.Sprintf("Marker fájl írási hiba: %v", err), nil)
|
|
|
|
|
s.msg(r, "debug.api.marker_write_failed", err), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "Controller újraindítása setup módba...", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, s.msg(r, "debug.api.restarting_to_setup"), nil)
|
|
|
|
|
|
|
|
|
|
// Exit after response is sent so the container restarts into setup mode
|
|
|
|
|
go func() {
|
|
|
|
@@ -762,7 +765,7 @@ func (s *Server) debugAgentLogs(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if fetch == nil {
|
|
|
|
|
client, err := s.agentClient()
|
|
|
|
|
if err != nil {
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, false, "Az ügynök nincs konfigurálva ezen a rendszeren.", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, false, s.msg(r, "debug.api.agent_unconfigured"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
fetch = client.DebugLogs
|
|
|
|
@@ -775,7 +778,7 @@ func (s *Server) debugAgentLogs(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
if errors.As(err, &se) && se.Code == http.StatusNotFound {
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "", map[string]interface{}{
|
|
|
|
|
"unsupported": true,
|
|
|
|
|
"notice": "Az ügynök naplónézete az ügynök következő frissítése után érhető el.",
|
|
|
|
|
"notice": s.msg(r, "debug.api.agent_logs_unsupported"),
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
@@ -843,7 +846,7 @@ func (s *Server) debugAppExportBundles(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
bundles := appexport.ScanForBundles(drives)
|
|
|
|
|
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true,
|
|
|
|
|
fmt.Sprintf("%d csomag található", len(bundles)),
|
|
|
|
|
s.msg(r, "debug.api.bundles_found", len(bundles)),
|
|
|
|
|
map[string]interface{}{"bundles": bundles})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -857,7 +860,7 @@ func (s *Server) debugAppExportCleanup(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
staleFiles := appexport.ScanForStaleTempFiles(drives)
|
|
|
|
|
|
|
|
|
|
if len(staleFiles) == 0 {
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, "Nincs eltávolítandó temp fájl", nil)
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true, s.msg(r, "debug.api.no_temp_files"), nil)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -872,5 +875,5 @@ func (s *Server) debugAppExportCleanup(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
writeDebugJSON(w, http.StatusOK, true,
|
|
|
|
|
fmt.Sprintf("%d/%d temp fájl eltávolítva", removed, len(staleFiles)), nil)
|
|
|
|
|
s.msg(r, "debug.api.temp_files_removed", removed, len(staleFiles)), nil)
|
|
|
|
|
}
|
|
|
|
|