services

package
v0.0.0-...-0732b9d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 47 Imported by: 0

Documentation

Overview

Package services provides the core application services used across the backend. Services encapsulate business logic and external/system interactions such as notification delivery, backups, mail sending, uptime monitoring, and more. These are instantiated by the application startup code and wired into HTTP handlers to provide functionality to the frontend API.

Package services provides business logic for the application.

Package services provides business logic services for the application.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccessListNotFound    = errors.New("access list not found")
	ErrInvalidAccessListType = errors.New("invalid access list type")
	ErrInvalidIPAddress      = errors.New("invalid IP address or CIDR")
	ErrInvalidCountryCode    = errors.New("invalid country code")
	ErrAccessListInUse       = errors.New("access list is in use by proxy hosts")
)
View Source
var (
	// ErrGeoIPDatabaseNotLoaded is returned when attempting lookup without a loaded database.
	ErrGeoIPDatabaseNotLoaded = errors.New("geoip database not loaded")
	// ErrInvalidGeoIP is returned when the IP address cannot be parsed.
	ErrInvalidGeoIP = errors.New("invalid IP address")
	// ErrCountryNotFound is returned when no country code is found for the IP.
	ErrCountryNotFound = errors.New("country not found for IP")
)
View Source
var (
	ErrSecurityConfigNotFound = errors.New("security config not found")
	ErrInvalidAdminCIDR       = errors.New("invalid admin whitelist CIDR")
	ErrBreakGlassInvalid      = errors.New("break-glass token invalid")
)
View Source
var ErrCertInUse = fmt.Errorf("certificate is in use by one or more proxy hosts")

ErrCertInUse is returned when a certificate is linked to one or more proxy hosts.

View Source
var RFC1918PrivateNetworks = []string{
	"10.0.0.0/8",
	"172.16.0.0/12",
	"192.168.0.0/16",
	"127.0.0.0/8",
	"169.254.0.0/16",
	"fc00::/7",
	"fe80::/10",
	"::1/128",
}

RFC1918PrivateNetworks defines private IP ranges

View Source
var ValidAccessListTypes = []string{"whitelist", "blacklist", "geo_whitelist", "geo_blacklist"}

ValidAccessListTypes defines allowed access list types

Functions

func ReconcileCrowdSecOnStartup

func ReconcileCrowdSecOnStartup(db *gorm.DB, executor CrowdsecProcessManager, binPath, dataDir string)

ReconcileCrowdSecOnStartup checks if CrowdSec should be running based on DB settings and starts it if necessary. This handles container restart scenarios where the user's preference was to have CrowdSec enabled.

Types

type AccessListService

type AccessListService struct {
	// contains filtered or unexported fields
}

AccessListService handles access list CRUD and IP testing operations.

func NewAccessListService

func NewAccessListService(db *gorm.DB) *AccessListService

NewAccessListService creates a new AccessListService.

func (*AccessListService) Create

func (s *AccessListService) Create(acl *models.AccessList) error

Create creates a new access list with validation

func (*AccessListService) Delete

func (s *AccessListService) Delete(id uint) error

Delete deletes an access list if not in use

func (*AccessListService) GetByID

func (s *AccessListService) GetByID(id uint) (*models.AccessList, error)

GetByID retrieves an access list by ID

func (*AccessListService) GetByUUID

func (s *AccessListService) GetByUUID(uuidStr string) (*models.AccessList, error)

GetByUUID retrieves an access list by UUID

func (*AccessListService) GetGeoIPService

func (s *AccessListService) GetGeoIPService() *GeoIPService

GetGeoIPService returns the configured GeoIP service (may be nil).

func (*AccessListService) GetTemplates

func (s *AccessListService) GetTemplates() []map[string]interface{}

GetTemplates returns predefined ACL templates

func (*AccessListService) List

func (s *AccessListService) List() ([]models.AccessList, error)

List retrieves all access lists sorted by updated_at desc

func (*AccessListService) SetGeoIPService

func (s *AccessListService) SetGeoIPService(geoipSvc *GeoIPService)

SetGeoIPService sets the GeoIP service for geo-based access list lookups. This method allows optional injection of the GeoIP service.

func (*AccessListService) TestIP

func (s *AccessListService) TestIP(aclID uint, ipAddress string) (allowed bool, reason string, err error)

TestIP tests if an IP address would be allowed/blocked by the access list

func (*AccessListService) Update

func (s *AccessListService) Update(id uint, updates *models.AccessList) error

Update updates an existing access list with validation

type AuthService

type AuthService struct {
	// contains filtered or unexported fields
}

func NewAuthService

func NewAuthService(db *gorm.DB, cfg config.Config) *AuthService

func (*AuthService) ChangePassword

func (s *AuthService) ChangePassword(userID uint, oldPassword, newPassword string) error

func (*AuthService) GenerateToken

func (s *AuthService) GenerateToken(user *models.User) (string, error)

func (*AuthService) GetUserByID

func (s *AuthService) GetUserByID(id uint) (*models.User, error)

func (*AuthService) Login

func (s *AuthService) Login(email, password string) (string, error)

func (*AuthService) Register

func (s *AuthService) Register(email, password, name string) (*models.User, error)

func (*AuthService) ValidateToken

func (s *AuthService) ValidateToken(tokenString string) (*Claims, error)

type BackupFile

type BackupFile struct {
	Filename string    `json:"filename"`
	Size     int64     `json:"size"`
	Time     time.Time `json:"time"`
}

type BackupService

type BackupService struct {
	DataDir      string
	BackupDir    string
	DatabaseName string
	Cron         *cron.Cron
}

func NewBackupService

func NewBackupService(cfg *config.Config) *BackupService

func (*BackupService) CreateBackup

func (s *BackupService) CreateBackup() (string, error)

CreateBackup creates a zip archive of the database and caddy data

func (*BackupService) DeleteBackup

func (s *BackupService) DeleteBackup(filename string) error

DeleteBackup removes a backup file

func (*BackupService) GetAvailableSpace

func (s *BackupService) GetAvailableSpace() (int64, error)

GetAvailableSpace returns the available disk space in bytes for the backup directory

func (*BackupService) GetBackupPath

func (s *BackupService) GetBackupPath(filename string) (string, error)

GetBackupPath returns the full path to a backup file (for downloading)

func (*BackupService) ListBackups

func (s *BackupService) ListBackups() ([]BackupFile, error)

ListBackups returns all backup files sorted by time (newest first)

func (*BackupService) RestoreBackup

func (s *BackupService) RestoreBackup(filename string) error

RestoreBackup restores the database and caddy data from a zip archive

func (*BackupService) RunScheduledBackup

func (s *BackupService) RunScheduledBackup()

type CertificateInfo

type CertificateInfo struct {
	ID        uint      `json:"id,omitempty"`
	UUID      string    `json:"uuid,omitempty"`
	Name      string    `json:"name,omitempty"`
	Domain    string    `json:"domain"`
	Issuer    string    `json:"issuer"`
	ExpiresAt time.Time `json:"expires_at"`
	Status    string    `json:"status"`   // "valid", "expiring", "expired", "untrusted"
	Provider  string    `json:"provider"` // "letsencrypt", "letsencrypt-staging", "custom"
}

CertificateInfo represents parsed certificate details.

type CertificateService

type CertificateService struct {
	// contains filtered or unexported fields
}

CertificateService manages certificate retrieval and parsing.

func NewCertificateService

func NewCertificateService(dataDir string, db *gorm.DB) *CertificateService

NewCertificateService creates a new certificate service.

func (*CertificateService) DeleteCertificate

func (s *CertificateService) DeleteCertificate(id uint) error

DeleteCertificate removes a certificate.

func (*CertificateService) InvalidateCache

func (s *CertificateService) InvalidateCache()

InvalidateCache clears the cache, forcing a blocking resync on next ListCertificates call.

func (*CertificateService) IsCertificateInUse

func (s *CertificateService) IsCertificateInUse(id uint) (bool, error)

IsCertificateInUse checks if a certificate is referenced by any proxy host.

func (*CertificateService) ListCertificates

func (s *CertificateService) ListCertificates() ([]CertificateInfo, error)

ListCertificates returns cached certificate info. Fast path: returns from cache if available. Triggers background rescan if cache is stale.

func (*CertificateService) SyncFromDisk

func (s *CertificateService) SyncFromDisk() error

SyncFromDisk scans the certificate directory and syncs with database. This is called on startup and can be triggered manually for refresh.

func (*CertificateService) UploadCertificate

func (s *CertificateService) UploadCertificate(name, certPEM, keyPEM string) (*models.SSLCertificate, error)

UploadCertificate saves a new custom certificate.

type Claims

type Claims struct {
	UserID uint   `json:"user_id"`
	Role   string `json:"role"`
	jwt.RegisteredClaims
}

type CrowdsecProcessManager

type CrowdsecProcessManager interface {
	Start(ctx context.Context, binPath, configDir string) (int, error)
	Stop(ctx context.Context, configDir string) error
	Status(ctx context.Context, configDir string) (running bool, pid int, err error)
}

CrowdsecProcessManager abstracts starting/stopping/status of CrowdSec process. This interface is structurally compatible with handlers.CrowdsecExecutor.

type DockerContainer

type DockerContainer struct {
	ID      string       `json:"id"`
	Names   []string     `json:"names"`
	Image   string       `json:"image"`
	State   string       `json:"state"`
	Status  string       `json:"status"`
	Network string       `json:"network"`
	IP      string       `json:"ip"`
	Ports   []DockerPort `json:"ports"`
}

type DockerPort

type DockerPort struct {
	PrivatePort uint16 `json:"private_port"`
	PublicPort  uint16 `json:"public_port"`
	Type        string `json:"type"`
}

type DockerService

type DockerService struct {
	// contains filtered or unexported fields
}

func NewDockerService

func NewDockerService() (*DockerService, error)

func (*DockerService) ListContainers

func (s *DockerService) ListContainers(ctx context.Context, host string) ([]DockerContainer, error)

type GeoIPService

type GeoIPService struct {
	// contains filtered or unexported fields
}

GeoIPService provides IP-to-country lookups using MaxMind GeoLite2.

func NewGeoIPService

func NewGeoIPService(dbPath string) (*GeoIPService, error)

NewGeoIPService creates a new GeoIPService and loads the database. Returns an error if the database cannot be loaded.

func (*GeoIPService) Close

func (s *GeoIPService) Close() error

Close releases the database resources.

func (*GeoIPService) GetDatabasePath

func (s *GeoIPService) GetDatabasePath() string

GetDatabasePath returns the configured database path.

func (*GeoIPService) IsLoaded

func (s *GeoIPService) IsLoaded() bool

IsLoaded returns true if the GeoIP database is currently loaded.

func (*GeoIPService) Load

func (s *GeoIPService) Load() error

Load opens or reloads the GeoIP database. This method is thread-safe and can be called to hot-reload the database.

func (*GeoIPService) LookupCountry

func (s *GeoIPService) LookupCountry(ipStr string) (string, error)

LookupCountry returns the ISO 3166-1 alpha-2 country code for an IP address. Returns ErrGeoIPDatabaseNotLoaded if database is not loaded, ErrInvalidGeoIP if the IP cannot be parsed, or ErrCountryNotFound if no country is associated with the IP.

type LogFile

type LogFile struct {
	Name    string `json:"name"`
	Size    int64  `json:"size"`
	ModTime string `json:"mod_time"`
}

type LogService

type LogService struct {
	LogDir string
}

func NewLogService

func NewLogService(cfg *config.Config) *LogService

func (*LogService) GetLogPath

func (s *LogService) GetLogPath(filename string) (string, error)

GetLogPath returns the absolute path to a log file if it exists and is valid

func (*LogService) ListLogs

func (s *LogService) ListLogs() ([]LogFile, error)

func (*LogService) QueryLogs

func (s *LogService) QueryLogs(filename string, filter models.LogFilter) ([]models.CaddyAccessLog, int64, error)

QueryLogs parses and filters logs from a specific file

type LogWatcher

type LogWatcher struct {
	// contains filtered or unexported fields
}

LogWatcher provides real-time tailing of Caddy access logs. It is a singleton service that can have multiple WebSocket clients subscribe to receive security-relevant log entries in real-time.

func NewLogWatcher

func NewLogWatcher(logPath string) *LogWatcher

NewLogWatcher creates a new LogWatcher instance for the given log file path.

func (*LogWatcher) ParseLogEntry

func (w *LogWatcher) ParseLogEntry(line string) *models.SecurityLogEntry

ParseLogEntry converts a Caddy JSON log line into a SecurityLogEntry. Returns nil if the line cannot be parsed.

func (*LogWatcher) Start

func (w *LogWatcher) Start(ctx context.Context) error

Start begins tailing the log file. This method is idempotent.

func (*LogWatcher) Stop

func (w *LogWatcher) Stop()

Stop halts the log watcher and closes all subscriber channels.

func (*LogWatcher) Subscribe

func (w *LogWatcher) Subscribe() <-chan models.SecurityLogEntry

Subscribe adds a new subscriber and returns a channel for receiving log entries. The caller is responsible for calling Unsubscribe when done.

func (*LogWatcher) Unsubscribe

func (w *LogWatcher) Unsubscribe(ch <-chan models.SecurityLogEntry)

Unsubscribe removes a subscriber channel.

type MailService

type MailService struct {
	// contains filtered or unexported fields
}

MailService handles sending emails via SMTP.

func NewMailService

func NewMailService(db *gorm.DB) *MailService

NewMailService creates a new mail service instance.

func (*MailService) GetSMTPConfig

func (s *MailService) GetSMTPConfig() (*SMTPConfig, error)

GetSMTPConfig retrieves SMTP settings from the database.

func (*MailService) IsConfigured

func (s *MailService) IsConfigured() bool

IsConfigured returns true if SMTP is properly configured.

func (*MailService) SaveSMTPConfig

func (s *MailService) SaveSMTPConfig(config *SMTPConfig) error

SaveSMTPConfig saves SMTP settings to the database.

func (*MailService) SendEmail

func (s *MailService) SendEmail(to, subject, htmlBody string) error

SendEmail sends an email using the configured SMTP settings. The to address and subject are sanitized to prevent header injection.

func (*MailService) SendInvite

func (s *MailService) SendInvite(email, inviteToken, appName, baseURL string) error

SendInvite sends an invitation email to a new user.

func (*MailService) TestConnection

func (s *MailService) TestConnection() error

TestConnection tests the SMTP connection without sending an email.

type NotificationService

type NotificationService struct {
	DB *gorm.DB
}

func NewNotificationService

func NewNotificationService(db *gorm.DB) *NotificationService

func (*NotificationService) Create

func (s *NotificationService) Create(nType models.NotificationType, title, message string) (*models.Notification, error)

func (*NotificationService) CreateProvider

func (s *NotificationService) CreateProvider(provider *models.NotificationProvider) error

func (*NotificationService) CreateTemplate

func (s *NotificationService) CreateTemplate(t *models.NotificationTemplate) error

CreateTemplate stores a new notification template in the database.

func (*NotificationService) DeleteProvider

func (s *NotificationService) DeleteProvider(id string) error

func (*NotificationService) DeleteTemplate

func (s *NotificationService) DeleteTemplate(id string) error

DeleteTemplate removes a notification template by its ID.

func (*NotificationService) GetTemplate

GetTemplate returns a single notification template by its ID.

func (*NotificationService) List

func (s *NotificationService) List(unreadOnly bool) ([]models.Notification, error)

func (*NotificationService) ListProviders

func (s *NotificationService) ListProviders() ([]models.NotificationProvider, error)

func (*NotificationService) ListTemplates

func (s *NotificationService) ListTemplates() ([]models.NotificationTemplate, error)

ListTemplates returns all external notification templates stored in the database.

func (*NotificationService) MarkAllAsRead

func (s *NotificationService) MarkAllAsRead() error

func (*NotificationService) MarkAsRead

func (s *NotificationService) MarkAsRead(id string) error

func (*NotificationService) RenderTemplate

func (s *NotificationService) RenderTemplate(p models.NotificationProvider, data map[string]interface{}) (resp string, parsed interface{}, err error)

RenderTemplate renders a provider template with provided data and returns the rendered JSON string and the parsed object for previewing/validation.

func (*NotificationService) SendExternal

func (s *NotificationService) SendExternal(ctx context.Context, eventType, title, message string, data map[string]interface{})

func (*NotificationService) TestProvider

func (s *NotificationService) TestProvider(provider models.NotificationProvider) error

func (*NotificationService) UpdateProvider

func (s *NotificationService) UpdateProvider(provider *models.NotificationProvider) error

func (*NotificationService) UpdateTemplate

func (s *NotificationService) UpdateTemplate(t *models.NotificationTemplate) error

UpdateTemplate saves updates to an existing notification template.

type ProxyHostService

type ProxyHostService struct {
	// contains filtered or unexported fields
}

ProxyHostService encapsulates business logic for proxy host management.

func NewProxyHostService

func NewProxyHostService(db *gorm.DB) *ProxyHostService

NewProxyHostService creates a new proxy host service.

func (*ProxyHostService) Create

func (s *ProxyHostService) Create(host *models.ProxyHost) error

Create validates and creates a new proxy host.

func (*ProxyHostService) Delete

func (s *ProxyHostService) Delete(id uint) error

Delete removes a proxy host.

func (*ProxyHostService) GetByID

func (s *ProxyHostService) GetByID(id uint) (*models.ProxyHost, error)

GetByID retrieves a proxy host by ID.

func (*ProxyHostService) GetByUUID

func (s *ProxyHostService) GetByUUID(uuidStr string) (*models.ProxyHost, error)

GetByUUID finds a proxy host by UUID.

func (*ProxyHostService) List

func (s *ProxyHostService) List() ([]models.ProxyHost, error)

List returns all proxy hosts.

func (*ProxyHostService) TestConnection

func (s *ProxyHostService) TestConnection(host string, port int) error

TestConnection attempts to connect to the target host and port.

func (*ProxyHostService) Update

func (s *ProxyHostService) Update(host *models.ProxyHost) error

Update validates and updates an existing proxy host.

func (*ProxyHostService) ValidateUniqueDomain

func (s *ProxyHostService) ValidateUniqueDomain(domainNames string, excludeID uint) error

ValidateUniqueDomain ensures no duplicate domains exist before creation/update.

type RemoteServerService

type RemoteServerService struct {
	// contains filtered or unexported fields
}

RemoteServerService encapsulates business logic for remote server management.

func NewRemoteServerService

func NewRemoteServerService(db *gorm.DB) *RemoteServerService

NewRemoteServerService creates a new remote server service.

func (*RemoteServerService) Create

func (s *RemoteServerService) Create(server *models.RemoteServer) error

Create validates and creates a new remote server.

func (*RemoteServerService) Delete

func (s *RemoteServerService) Delete(id uint) error

Delete removes a remote server.

func (*RemoteServerService) GetByID

func (s *RemoteServerService) GetByID(id uint) (*models.RemoteServer, error)

GetByID retrieves a remote server by ID.

func (*RemoteServerService) GetByUUID

func (s *RemoteServerService) GetByUUID(uuidStr string) (*models.RemoteServer, error)

GetByUUID retrieves a remote server by UUID.

func (*RemoteServerService) List

func (s *RemoteServerService) List(enabledOnly bool) ([]models.RemoteServer, error)

List retrieves all remote servers, optionally filtering by enabled status.

func (*RemoteServerService) Update

func (s *RemoteServerService) Update(server *models.RemoteServer) error

Update validates and updates an existing remote server.

func (*RemoteServerService) ValidateUniqueServer

func (s *RemoteServerService) ValidateUniqueServer(name, host string, port int, excludeID uint) error

ValidateUniqueServer ensures no duplicate name+host+port combinations.

type SMTPConfig

type SMTPConfig struct {
	Host        string `json:"host"`
	Port        int    `json:"port"`
	Username    string `json:"username"`
	Password    string `json:"password"`
	FromAddress string `json:"from_address"`
	Encryption  string `json:"encryption"` // "none", "ssl", "starttls"
}

SMTPConfig holds the SMTP server configuration.

type SecurityNotificationService

type SecurityNotificationService struct {
	// contains filtered or unexported fields
}

SecurityNotificationService handles dispatching security event notifications.

func NewSecurityNotificationService

func NewSecurityNotificationService(db *gorm.DB) *SecurityNotificationService

NewSecurityNotificationService creates a new SecurityNotificationService instance.

func (*SecurityNotificationService) GetSettings

GetSettings retrieves the notification configuration.

func (*SecurityNotificationService) Send

Send dispatches a security event to configured channels.

func (*SecurityNotificationService) UpdateSettings

func (s *SecurityNotificationService) UpdateSettings(config *models.NotificationConfig) error

UpdateSettings updates the notification configuration.

type SecurityService

type SecurityService struct {
	// contains filtered or unexported fields
}

func NewSecurityService

func NewSecurityService(db *gorm.DB) *SecurityService

NewSecurityService returns a SecurityService using the provided DB

func (*SecurityService) DeleteRuleSet

func (s *SecurityService) DeleteRuleSet(id uint) error

DeleteRuleSet removes a ruleset by id

func (*SecurityService) GenerateBreakGlassToken

func (s *SecurityService) GenerateBreakGlassToken(name string) (string, error)

GenerateBreakGlassToken generates a token, stores its bcrypt hash, and returns the plaintext token

func (*SecurityService) Get

Get returns the first SecurityConfig row (singleton config)

func (*SecurityService) ListDecisions

func (s *SecurityService) ListDecisions(limit int) ([]models.SecurityDecision, error)

ListDecisions returns recent security decisions, ordered by created_at desc

func (*SecurityService) ListRuleSets

func (s *SecurityService) ListRuleSets() ([]models.SecurityRuleSet, error)

ListRuleSets returns all known rulesets

func (*SecurityService) LogAudit

func (s *SecurityService) LogAudit(a *models.SecurityAudit) error

LogAudit stores an audit entry

func (*SecurityService) LogDecision

func (s *SecurityService) LogDecision(d *models.SecurityDecision) error

LogDecision stores a security decision record

func (*SecurityService) Upsert

func (s *SecurityService) Upsert(cfg *models.SecurityConfig) error

Upsert validates and saves a security config

func (*SecurityService) UpsertRuleSet

func (s *SecurityService) UpsertRuleSet(r *models.SecurityRuleSet) error

UpsertRuleSet saves or updates a ruleset content

func (*SecurityService) VerifyBreakGlassToken

func (s *SecurityService) VerifyBreakGlassToken(name, token string) (bool, error)

VerifyBreakGlassToken validates a provided token against the stored hash

type UpdateInfo

type UpdateInfo struct {
	Available     bool   `json:"available"`
	LatestVersion string `json:"latest_version"`
	ChangelogURL  string `json:"changelog_url"`
}

type UpdateService

type UpdateService struct {
	// contains filtered or unexported fields
}

func NewUpdateService

func NewUpdateService() *UpdateService

func (*UpdateService) CheckForUpdates

func (s *UpdateService) CheckForUpdates() (*UpdateInfo, error)

func (*UpdateService) ClearCache

func (s *UpdateService) ClearCache()

ClearCache clears the update cache for testing.

func (*UpdateService) SetAPIURL

func (s *UpdateService) SetAPIURL(url string)

SetAPIURL sets the GitHub API URL for testing.

func (*UpdateService) SetCurrentVersion

func (s *UpdateService) SetCurrentVersion(v string)

SetCurrentVersion sets the current version for testing.

type UptimeService

type UptimeService struct {
	DB                  *gorm.DB
	NotificationService *NotificationService
	// contains filtered or unexported fields
}

func NewUptimeService

func NewUptimeService(db *gorm.DB, ns *NotificationService) *UptimeService

func (*UptimeService) CheckAll

func (s *UptimeService) CheckAll()

CheckAll runs checks for all enabled monitors with host-level pre-check

func (*UptimeService) CheckMonitor

func (s *UptimeService) CheckMonitor(monitor models.UptimeMonitor)

CheckMonitor is the exported version for on-demand checks

func (*UptimeService) DeleteMonitor

func (s *UptimeService) DeleteMonitor(id string) error

DeleteMonitor removes a monitor and its heartbeats, and optionally cleans up the parent UptimeHost.

func (*UptimeService) FlushPendingNotifications

func (s *UptimeService) FlushPendingNotifications()

FlushPendingNotifications flushes all pending batched notifications immediately. This is useful for testing and graceful shutdown.

func (*UptimeService) GetMonitorByID

func (s *UptimeService) GetMonitorByID(id string) (*models.UptimeMonitor, error)

func (*UptimeService) GetMonitorHistory

func (s *UptimeService) GetMonitorHistory(id string, limit int) ([]models.UptimeHeartbeat, error)

func (*UptimeService) ListMonitors

func (s *UptimeService) ListMonitors() ([]models.UptimeMonitor, error)

func (*UptimeService) SyncMonitorForHost

func (s *UptimeService) SyncMonitorForHost(hostID uint) error

SyncMonitorForHost updates the uptime monitor linked to a specific proxy host. This should be called when a proxy host is edited to keep the monitor in sync. Returns nil if no monitor exists for the host (does not create one).

func (*UptimeService) SyncMonitors

func (s *UptimeService) SyncMonitors() error

SyncMonitors ensures every ProxyHost and RemoteServer has a corresponding UptimeMonitor and that UptimeHosts are created for grouping

func (*UptimeService) UpdateMonitor

func (s *UptimeService) UpdateMonitor(id string, updates map[string]interface{}) (*models.UptimeMonitor, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL