Files
cloud-ip-validator/internal/dashboard/routes.go
T
ayurishchevandClaude Sonnet 5.5 cd37b10f3b Add optional automatic check cycle (clear queue -> scan FIPs -> wait -> repeat)
An admin-controlled scenario that repeats what the operator does by hand:
clear the IP queue, scan and enqueue all free Floating IPs, wait until every
queued address reaches a terminal state (so results are in the Registry),
then wait a configurable interval and start over.

- control-api: new auto_cycle singleton table (migration 0008) holding
  enabled/interval/max-run settings and persisted phase state, so the cycle
  survives restarts; engine in orchestrator/autocycle.go driven from the
  existing loop tick with an injectable "now" for deterministic tests.
- Interval (default 1h, min 60s) and max wait (default unlimited, timeout
  outcome) are runtime settings, never hardcoded.
- The periodic fip_scan_interval_seconds scan is skipped while the cycle is
  enabled. An emptied queue mid-cycle counts as finished; stopping during
  the pause keeps the last cycle's outcome.
- API: GET/PUT /api/v1/admin/auto-cycle, POST .../start, POST .../stop.
- admin-dashboard: "Автоматический цикл" panel on /settings and an
  "Автоцикл активен" indicator on /overview.
- Tests for db, orchestrator, httpapi and dashboard; run-local-e2e.sh now
  exercises a full auto cycle; docs updated; bin/ rebuilt with refreshed
  SHA256SUMS.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-01 10:28:53 +03:00

58 lines
2.4 KiB
Go

package dashboard
import "net/http"
func (s *Server) routes(mux *http.ServeMux) {
mux.HandleFunc("GET /{$}", s.handleIndex)
mux.HandleFunc("GET /overview", s.handleOverview)
mux.HandleFunc("GET /overview/fragment", s.handleOverviewFragment)
mux.HandleFunc("GET /ips", s.handleIPsPage)
mux.HandleFunc("GET /ips/{ip}", s.handleIPDetail)
mux.HandleFunc("POST /ips", s.handleIPsSubmit)
mux.HandleFunc("POST /ips/scan", s.handleIPsScan)
mux.HandleFunc("POST /ips/{ip}/recheck", s.handleIPRecheck)
mux.HandleFunc("POST /ips/{ip}/cancel", s.handleIPCancel)
mux.HandleFunc("DELETE /ips/{ip}", s.handleIPDelete)
mux.HandleFunc("POST /ips/delete", s.handleIPsDeleteSelected)
mux.HandleFunc("POST /ips/recheck", s.handleIPsRecheckSelected)
mux.HandleFunc("POST /ips/clear", s.handleIPsClear)
mux.HandleFunc("GET /registry", s.handleRegistryPage)
mux.HandleFunc("GET /registry/{ip}", s.handleRegistryDetail)
mux.HandleFunc("GET /validators", s.handleValidatorsPage)
mux.HandleFunc("POST /validators", s.handleValidatorCreate)
mux.HandleFunc("PUT /validators/{id}", s.handleValidatorUpdate)
mux.HandleFunc("DELETE /validators/{id}", s.handleValidatorDelete)
mux.HandleFunc("GET /sites", s.handleSitesPage)
mux.HandleFunc("POST /sites", s.handleSiteCreate)
mux.HandleFunc("PUT /sites/{index}", s.handleSitePut)
mux.HandleFunc("DELETE /sites/{index}", s.handleSiteDelete)
mux.HandleFunc("GET /targets", s.handleTargetsPage)
mux.HandleFunc("POST /targets", s.handleTargetCreate)
mux.HandleFunc("PUT /targets/{group}", s.handleTargetUpdate)
mux.HandleFunc("DELETE /targets/{group}", s.handleTargetDelete)
mux.HandleFunc("GET /check-types", s.handleCheckTypesPage)
mux.HandleFunc("POST /check-types", s.handleCheckTypeCreate)
mux.HandleFunc("PUT /check-types/{name}", s.handleCheckTypeUpdate)
mux.HandleFunc("DELETE /check-types/{name}", s.handleCheckTypeDelete)
mux.HandleFunc("GET /settings", s.handleSettingsPage)
mux.HandleFunc("PUT /settings", s.handleSettingsPut)
mux.HandleFunc("PUT /settings/inbound-checks", s.handleInboundChecksPut)
mux.HandleFunc("PUT /settings/auto-cycle", s.handleAutoCyclePut)
mux.HandleFunc("POST /settings/auto-cycle/start", s.handleAutoCycleStart)
mux.HandleFunc("POST /settings/auto-cycle/stop", s.handleAutoCycleStop)
mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServerFS(staticSubFS())))
}
func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/overview", http.StatusFound)
}