e97780ad38
Prevent accidental deletes with y/n confirmation dialog. Validate all numeric form inputs (interval, port, timeout, threshold, retries) with range checks instead of silently defaulting to zero. Escape user-supplied data in status page JavaScript to close XSS via monitor names. Persist check history to new check_history table so sparklines and uptime percentages survive restarts.
48 lines
972 B
Go
48 lines
972 B
Go
package store
|
|
|
|
import (
|
|
"go-upkeep/internal/models"
|
|
)
|
|
|
|
type Store interface {
|
|
Init() error
|
|
|
|
// Sites
|
|
GetSites() []models.Site
|
|
AddSite(site models.Site)
|
|
UpdateSite(site models.Site)
|
|
UpdateSitePaused(id int, paused bool)
|
|
DeleteSite(id int)
|
|
|
|
// Alerts
|
|
GetAllAlerts() []models.AlertConfig
|
|
GetAlert(id int) (models.AlertConfig, bool)
|
|
AddAlert(name, aType string, settings map[string]string)
|
|
UpdateAlert(id int, name, aType string, settings map[string]string)
|
|
DeleteAlert(id int)
|
|
|
|
// Users
|
|
GetAllUsers() []models.User
|
|
AddUser(username, publicKey, role string) error
|
|
UpdateUser(id int, username, publicKey, role string) error
|
|
DeleteUser(id int) error
|
|
|
|
// History
|
|
SaveCheck(siteID int, latencyNs int64, isUp bool)
|
|
LoadAllHistory(limit int) map[int][]models.CheckRecord
|
|
|
|
// Backup & Restore
|
|
ExportData() models.Backup
|
|
ImportData(data models.Backup) error
|
|
}
|
|
|
|
var Current Store
|
|
|
|
func SetGlobal(s Store) {
|
|
Current = s
|
|
}
|
|
|
|
func Get() Store {
|
|
return Current
|
|
}
|