service

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResources added in v0.0.10

func CheckResources(ctx context.Context, notify NotifyFunc) error

CheckResources checks system resource usage and alerts if thresholds are exceeded.

func GetResources added in v0.0.10

func GetResources() *model.SystemResources

GetResources returns current system resource usage.

func InstallSystemdService

func InstallSystemdService() error

InstallSystemdService creates and enables the popugate systemd service.

func IsDockerEnvironment added in v0.0.6

func IsDockerEnvironment() bool

IsDockerEnvironment detects if the process is running inside a Docker container.

func IsSafeGitRef added in v0.0.7

func IsSafeGitRef(ref string) bool

IsSafeGitRef validates that a git ref (commit/branch/tag) only contains safe characters.

func IsSystemdInstalled

func IsSystemdInstalled() bool

IsSystemdInstalled checks if the popugate service is installed.

func IsValidCountryCode added in v0.0.4

func IsValidCountryCode(code string) bool

IsValidCountryCode checks that a code is a valid ISO 3166-1 alpha-2 country code.

func ReloadService

func ReloadService() error

ReloadService sends a reload signal to the systemd service.

func RestartService

func RestartService() error

RestartService restarts the popugate systemd service.

func UninstallSystemdService

func UninstallSystemdService() error

UninstallSystemdService removes the systemd service.

Types

type AuditService added in v0.0.10

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

AuditService handles audit log business logic.

func NewAuditService added in v0.0.10

func NewAuditService(audit *store.AuditStore) *AuditService

NewAuditService creates a new AuditService.

func (*AuditService) CleanOld added in v0.0.10

func (s *AuditService) CleanOld(ctx context.Context) (int, error)

CleanOld removes audit entries older than 30 days.

func (*AuditService) List added in v0.0.10

func (s *AuditService) List(ctx context.Context, limit, offset int) ([]model.AuditEntry, error)

List returns audit entries with pagination.

func (*AuditService) Log added in v0.0.10

func (s *AuditService) Log(ctx context.Context, user, action, detail string) error

Log records an audit entry.

type BuildResult

type BuildResult struct {
	Method  string `json:"method"` // "registry", "latest", "source", "cached"
	Version string `json:"version"`
	Message string `json:"message"`
}

BuildResult holds the outcome of a build attempt.

type ContainerService

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

ContainerService manages proxy container lifecycle.

func NewContainerService

func NewContainerService(
	docker *dockerutil.DockerClient,
	secrets *store.SecretStore,
	upstreams *store.UpstreamStore,
	instances *store.InstanceStore,
	traffic *store.TrafficStore,
	settings *store.SettingsStore,
	trafficSvc *TrafficService,
) *ContainerService

NewContainerService creates a new ContainerService.

func (*ContainerService) Reload

func (s *ContainerService) Reload(ctx context.Context) error

Reload regenerates config and sends SIGHUP for hot-reload.

func (*ContainerService) Restart

func (s *ContainerService) Restart(ctx context.Context) error

Restart stops and starts the proxy.

func (*ContainerService) SetNotify added in v0.0.9

func (s *ContainerService) SetNotify(fn NotifyFunc)

SetNotify sets the notification callback.

func (*ContainerService) Start

func (s *ContainerService) Start(ctx context.Context) error

Start starts all enabled proxy instances.

func (*ContainerService) Status

Status returns the current status of all proxy instances.

func (*ContainerService) Stop

func (s *ContainerService) Stop(ctx context.Context) error

Stop stops all proxy instances.

type DBTelemtConfig added in v0.0.7

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

DBTelemtConfig reads telemt configuration from the database with env/constant fallback. Results are cached for up to cacheTTL to avoid querying the DB on every call.

func NewDBTelemtConfig added in v0.0.7

func NewDBTelemtConfig(s *store.SettingsStore) *DBTelemtConfig

NewDBTelemtConfig creates a new DBTelemtConfig.

func (*DBTelemtConfig) InvalidateCache added in v0.0.7

func (c *DBTelemtConfig) InvalidateCache()

InvalidateCache forces a reload on next access.

func (*DBTelemtConfig) SetCacheTTL added in v0.0.7

func (c *DBTelemtConfig) SetCacheTTL(d time.Duration)

SetCacheTTL changes the cache TTL (for testing).

func (*DBTelemtConfig) TelemtCommit added in v0.0.7

func (c *DBTelemtConfig) TelemtCommit() string

func (*DBTelemtConfig) TelemtRepo added in v0.0.7

func (c *DBTelemtConfig) TelemtRepo() string

func (*DBTelemtConfig) TelemtVersion added in v0.0.7

func (c *DBTelemtConfig) TelemtVersion() string

type DockerService

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

DockerService handles Docker installation and engine image management.

func NewDockerService

func NewDockerService(docker *dockerutil.DockerClient, telemtCfg TelemtConfigProvider) *DockerService

NewDockerService creates a new DockerService.

func (*DockerService) BuildEngine

func (s *DockerService) BuildEngine(ctx context.Context, force bool) (*BuildResult, error)

BuildEngine implements the three-tier image build strategy: 1. Pull exact version from registry 2. Pull :latest from registry 3. Build from source

func (*DockerService) GetInstalledVersion

func (s *DockerService) GetInstalledVersion() string

GetInstalledVersion returns the currently installed telemt version string.

type GeoblockService

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

GeoblockService handles geo-blocking via iptables/ipset.

func NewGeoblockService

func NewGeoblockService(settings *store.SettingsStore, instances *store.InstanceStore, cache *store.GeoblockCacheStore) *GeoblockService

NewGeoblockService creates a new GeoblockService.

func (*GeoblockService) Apply

func (s *GeoblockService) Apply(ctx context.Context) error

Apply downloads CIDRs for all configured countries and applies iptables rules.

func (*GeoblockService) Clear

func (s *GeoblockService) Clear(ctx context.Context) error

Clear removes all geo-blocking rules.

type HealthService

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

HealthService provides health diagnostics and auto-recovery.

func NewHealthService

func NewHealthService(docker *dockerutil.DockerClient, settings *store.SettingsStore, instances *store.InstanceStore) *HealthService

NewHealthService creates a new HealthService.

func (*HealthService) AutoRecover

func (h *HealthService) AutoRecover(ctx context.Context) error

AutoRecover attempts to start the proxy if it's unexpectedly stopped.

func (*HealthService) Check

func (h *HealthService) Check(ctx context.Context) *HealthStatus

Check runs all health checks.

func (*HealthService) SetContainerSvc

func (h *HealthService) SetContainerSvc(svc *ContainerService)

SetContainerSvc sets the container service for auto-recovery.

type HealthStatus

type HealthStatus struct {
	Docker    string `json:"docker"`
	Container string `json:"container"`
	Port      string `json:"port"`
	Metrics   string `json:"metrics"`
	Details   string `json:"details,omitempty"`
}

HealthStatus holds the result of a health check.

type NotifyFunc added in v0.0.9

type NotifyFunc func(ctx context.Context, format string, args ...any)

NotifyFunc sends a formatted notification. The first %s verb in format is the server label, resolved automatically by the implementation. Implementations must be safe for concurrent use and silently skip when notifications are disabled or unavailable.

type OSType

type OSType struct {
	Family  string `json:"family"`
	Version string `json:"version"`
	Arch    string `json:"arch"`
}

OSType represents the details of the host OS.

func DetectOS

func DetectOS() *OSType

DetectOS detects the operating system details.

type ReplicationService

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

ReplicationService handles master/slave sync.

func NewReplicationService

func NewReplicationService(settings *store.SettingsStore, slaves *store.SlaveStore) *ReplicationService

NewReplicationService creates a new ReplicationService.

func (*ReplicationService) GenerateSSHKey

func (s *ReplicationService) GenerateSSHKey(ctx context.Context) (string, error)

GenerateSSHKey generates an ed25519 key pair for replication.

func (*ReplicationService) GetSSHPublicKey added in v0.0.5

func (s *ReplicationService) GetSSHPublicKey(ctx context.Context) (string, error)

GetSSHPublicKey reads the existing public key from disk.

func (*ReplicationService) SyncAll

SyncAll syncs to all enabled slaves (with lock file to prevent concurrent runs).

func (*ReplicationService) SyncSlave

func (s *ReplicationService) SyncSlave(ctx context.Context, host string) (*sshutil.SyncResult, error)

SyncSlave syncs to a specific slave.

func (*ReplicationService) TestSSH

TestSSH tests connectivity to a slave.

type ResourceMonitor added in v0.0.10

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

ResourceMonitor periodically collects system resources.

func GetResourceMonitor added in v0.0.10

func GetResourceMonitor() *ResourceMonitor

GetResourceMonitor returns the singleton instance of ResourceMonitor.

func InitResourceMonitor added in v0.0.10

func InitResourceMonitor(notify NotifyFunc) *ResourceMonitor

InitResourceMonitor initializes the singleton instance of ResourceMonitor.

func (*ResourceMonitor) GetCurrent added in v0.0.10

func (m *ResourceMonitor) GetCurrent() *model.SystemResources

GetCurrent returns the latest collected resources.

func (*ResourceMonitor) Stop added in v0.0.10

func (m *ResourceMonitor) Stop()

Stop stops the monitor.

func (*ResourceMonitor) Subscribe added in v0.0.10

func (m *ResourceMonitor) Subscribe() (chan *model.SystemResources, func())

Subscribe returns a channel that receives resource updates.

type SchedulerService added in v0.0.10

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

SchedulerService handles scheduler business logic.

func NewSchedulerService added in v0.0.10

func NewSchedulerService(store *store.SchedulerStore, sched *scheduler.Scheduler) *SchedulerService

NewSchedulerService creates a new SchedulerService.

func (*SchedulerService) GetAllHistory added in v0.0.10

func (svc *SchedulerService) GetAllHistory(ctx context.Context, limit, offset int) ([]scheduler.ExecutionRecord, error)

GetAllHistory returns execution history for all tasks.

func (*SchedulerService) GetHistory added in v0.0.10

func (svc *SchedulerService) GetHistory(ctx context.Context, taskName string, limit, offset int) ([]scheduler.ExecutionRecord, error)

GetHistory returns execution history for a specific task.

func (*SchedulerService) ListTasks added in v0.0.10

func (svc *SchedulerService) ListTasks(ctx context.Context) ([]scheduler.TaskStatus, error)

ListTasks returns all tasks with their current status and last run info.

func (*SchedulerService) RunTaskNow added in v0.0.10

func (svc *SchedulerService) RunTaskNow(ctx context.Context, name string) (*scheduler.ExecutionRecord, error)

RunTaskNow manually triggers a task.

func (*SchedulerService) UpdateTask added in v0.0.10

func (svc *SchedulerService) UpdateTask(ctx context.Context, name string, enabled *bool, schedule *string) error

UpdateTask changes a task's enabled state and/or schedule.

type SecretService

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

SecretService handles secret business logic.

func NewSecretService

func NewSecretService(secrets *store.SecretStore) *SecretService

NewSecretService creates a new SecretService.

func (*SecretService) Add

func (s *SecretService) Add(ctx context.Context, label, secretKey string) (*model.Secret, error)

Add creates a new secret. If secretKey is empty, generates one automatically.

func (*SecretService) Archive added in v0.0.10

func (s *SecretService) Archive(ctx context.Context, label string) error

Archive marks a secret as archived.

func (*SecretService) BulkExtend added in v0.0.10

func (s *SecretService) BulkExtend(ctx context.Context, labels []string, days int) (int, error)

BulkExtend extends expiry for multiple secrets.

func (*SecretService) BulkRotate added in v0.0.10

func (s *SecretService) BulkRotate(ctx context.Context, labels []string) (int, []string, error)

BulkRotate rotates keys for multiple secrets.

func (*SecretService) BulkSetLimits added in v0.0.10

func (s *SecretService) BulkSetLimits(ctx context.Context, labels []string, maxConns, maxIPs int, quotaBytes int64, expiresAt string) (int, error)

BulkSetLimits sets the same limits for multiple secrets.

func (*SecretService) BulkToggle added in v0.0.10

func (s *SecretService) BulkToggle(ctx context.Context, labels []string, enable bool) (int, error)

BulkToggle enables or disables multiple secrets.

func (*SecretService) Clone added in v0.0.10

func (s *SecretService) Clone(ctx context.Context, srcLabel, newLabel string) (*model.Secret, error)

Clone creates a copy of a secret with a new label and key.

func (*SecretService) DisableExpired added in v0.0.10

func (s *SecretService) DisableExpired(ctx context.Context) (int, error)

DisableExpired disables all secrets whose expiry is in the past. Returns the count of disabled secrets.

func (*SecretService) ExportJSON added in v0.0.10

func (s *SecretService) ExportJSON(ctx context.Context) ([]model.Secret, error)

ExportJSON returns all secrets as a JSON-serializable slice.

func (*SecretService) Extend added in v0.0.10

func (s *SecretService) Extend(ctx context.Context, label string, days int) error

Extend sets a new expiry for a secret. If days > 0, it sets expiry to now+days and optionally re-enables the secret.

func (*SecretService) Get

func (s *SecretService) Get(ctx context.Context, label string) (*model.Secret, error)

Get returns a single secret by label.

func (*SecretService) GetEnabledLabels

func (s *SecretService) GetEnabledLabels(ctx context.Context) ([]string, error)

GetEnabledLabels returns labels of all enabled secrets.

func (s *SecretService) GetLink(ctx context.Context, label, serverIP string, port int, maskingEnabled bool, domain string) (*model.SecretWithLink, error)

GetLink returns the proxy link for a secret.

func (*SecretService) GetQRCode

func (s *SecretService) GetQRCode(ctx context.Context, label, serverIP string, port int, maskingEnabled bool, domain string, size int) ([]byte, error)

GetQRCode generates a QR code PNG for a secret's proxy link.

func (*SecretService) ImportSecrets added in v0.0.10

func (s *SecretService) ImportSecrets(ctx context.Context, entries []model.Secret) (int, []string, error)

ImportSecrets creates multiple secrets from an import list.

func (*SecretService) LabelsByTag added in v0.0.10

func (s *SecretService) LabelsByTag(ctx context.Context, tag string) ([]string, error)

LabelsByTag resolves a tag to its constituent labels.

func (*SecretService) List

func (s *SecretService) List(ctx context.Context) ([]model.Secret, error)

List returns all secrets with traffic data.

func (*SecretService) ListAllTags added in v0.0.10

func (s *SecretService) ListAllTags(ctx context.Context) ([]string, error)

ListAllTags returns all unique tags.

func (*SecretService) ListByTag added in v0.0.10

func (s *SecretService) ListByTag(ctx context.Context, tag string) ([]model.Secret, error)

ListByTag returns secrets matching the given tag.

func (*SecretService) Remove

func (s *SecretService) Remove(ctx context.Context, label string, force bool) error

Remove deletes a secret. Refuses if it's the last enabled one.

func (*SecretService) Rename added in v0.0.10

func (s *SecretService) Rename(ctx context.Context, oldLabel, newLabel string) error

Rename changes a secret's label.

func (*SecretService) ResetAllTraffic

func (s *SecretService) ResetAllTraffic(ctx context.Context) error

ResetAllTraffic resets traffic for all users.

func (*SecretService) ResetTraffic

func (s *SecretService) ResetTraffic(ctx context.Context, label string) error

ResetTraffic resets traffic for a specific user.

func (*SecretService) Rotate

func (s *SecretService) Rotate(ctx context.Context, label string) (*model.Secret, error)

Rotate generates a new key for an existing secret, preserving the label and limits.

func (*SecretService) Search added in v0.0.10

func (s *SecretService) Search(ctx context.Context, query string) ([]model.Secret, error)

Search returns secrets matching a text query.

func (*SecretService) SetLimits

func (s *SecretService) SetLimits(ctx context.Context, label string, maxConns, maxIPs int, quotaBytes int64, expiresAt string) error

SetLimits updates per-user limits for a secret.

func (*SecretService) SetTags added in v0.0.10

func (s *SecretService) SetTags(ctx context.Context, label, tags string) error

SetTags updates the tags for a secret.

func (*SecretService) Toggle

func (s *SecretService) Toggle(ctx context.Context, label string, enable bool) error

Toggle enables or disables a secret.

func (*SecretService) Top added in v0.0.10

func (s *SecretService) Top(ctx context.Context, limit int) ([]model.Secret, error)

Top returns secrets ordered by traffic.

func (*SecretService) Unarchive added in v0.0.10

func (s *SecretService) Unarchive(ctx context.Context, label string) error

Unarchive removes the archived status from a secret.

func (*SecretService) UpdateNotes

func (s *SecretService) UpdateNotes(ctx context.Context, label, notes string) error

UpdateNotes updates the notes/description for a secret.

type SystemdServiceStatus

type SystemdServiceStatus struct {
	Supported bool   `json:"supported"`
	Installed bool   `json:"installed"`
	Active    string `json:"active"`
	Enabled   bool   `json:"enabled"`
	PID       string `json:"pid,omitempty"`
	Uptime    string `json:"uptime,omitempty"`
}

SystemdServiceStatus represents the status of the systemd service.

func GetServiceStatus

func GetServiceStatus() *SystemdServiceStatus

GetServiceStatus queries systemctl for detailed service status.

type TelemtConfigProvider added in v0.0.7

type TelemtConfigProvider interface {
	TelemtVersion() string
	TelemtCommit() string
	TelemtRepo() string
}

TelemtConfigProvider abstracts how telemt version/commit/repo are resolved.

type TelemtReleaseInfo added in v0.0.7

type TelemtReleaseInfo struct {
	Version     string `json:"version"`
	Commit      string `json:"commit,omitempty"`
	TagName     string `json:"tag_name,omitempty"`
	HTMLURL     string `json:"html_url,omitempty"`
	PublishedAt string `json:"published_at,omitempty"`
}

TelemtReleaseInfo holds information about a remote telemt release.

type TelemtReleaseListItem added in v0.0.7

type TelemtReleaseListItem struct {
	Version     string `json:"version"`
	Commit      string `json:"commit"`
	TagName     string `json:"tag_name"`
	HTMLURL     string `json:"html_url,omitempty"`
	PublishedAt string `json:"published_at,omitempty"`
	Prerelease  bool   `json:"prerelease"`
}

TelemtReleaseListItem is a trimmed release entry for the UI list.

type TelemtUpdateService added in v0.0.7

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

TelemtUpdateService handles checking and applying telemt engine updates.

func NewTelemtUpdateService added in v0.0.7

func NewTelemtUpdateService(
	settings *store.SettingsStore,
	dockerSvc *DockerService,
	containerSvc *ContainerService,
	telemtCfg *DBTelemtConfig,
) *TelemtUpdateService

NewTelemtUpdateService creates a new TelemtUpdateService.

func (*TelemtUpdateService) Apply added in v0.0.7

func (s *TelemtUpdateService) Apply(ctx context.Context, version, commit string) error

Apply performs the engine update: save version -> build image -> restart proxy. The proxy is NOT stopped during the build.

func (*TelemtUpdateService) CheckRemote added in v0.0.7

func (s *TelemtUpdateService) CheckRemote(ctx context.Context) (*TelemtReleaseInfo, error)

CheckRemote queries the GitHub API for the latest telemt release, fetches the full releases list, and caches everything.

func (*TelemtUpdateService) GetReleases added in v0.0.7

GetReleases returns the cached releases list from the DB.

func (*TelemtUpdateService) GetStatus added in v0.0.7

GetStatus returns the current vs. latest release info for the UI.

func (*TelemtUpdateService) ResetStaleUpdate added in v0.0.8

func (s *TelemtUpdateService) ResetStaleUpdate(ctx context.Context)

ResetStaleUpdate clears a stale "updating" flag left from a crash/restart. Should be called once at server startup.

func (*TelemtUpdateService) SetNotify added in v0.0.9

func (s *TelemtUpdateService) SetNotify(fn NotifyFunc)

SetNotify sets the notification callback.

func (*TelemtUpdateService) Subscribe added in v0.0.10

func (s *TelemtUpdateService) Subscribe() (chan *TelemtUpdateStatus, func())

Subscribe returns a channel that receives TelemtUpdateStatus updates.

type TelemtUpdateStatus added in v0.0.7

type TelemtUpdateStatus struct {
	Current         string             `json:"current"`
	Latest          *TelemtReleaseInfo `json:"latest,omitempty"`
	UpdateAvailable bool               `json:"update_available"`
	LastChecked     string             `json:"last_checked,omitempty"`
	Updating        bool               `json:"updating"`
	UpdatingTo      string             `json:"updating_to,omitempty"`
}

TelemtUpdateStatus is returned to the UI.

type TemplateService added in v0.0.10

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

TemplateService handles secret template business logic.

func NewTemplateService added in v0.0.10

func NewTemplateService(templates *store.TemplateStore, secrets *store.SecretStore) *TemplateService

NewTemplateService creates a new TemplateService.

func (*TemplateService) ApplyToSecret added in v0.0.10

func (s *TemplateService) ApplyToSecret(ctx context.Context, templateName, secretLabel string) error

ApplyToSecret applies a template's limits to a secret.

func (*TemplateService) Create added in v0.0.10

Create adds a new template.

func (*TemplateService) Delete added in v0.0.10

func (s *TemplateService) Delete(ctx context.Context, name string) error

Delete removes a template.

func (*TemplateService) Get added in v0.0.10

Get returns a template by name.

func (*TemplateService) List added in v0.0.10

List returns all templates.

type TrafficService

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

TrafficService handles traffic monitoring and persistence.

func NewTrafficService

func NewTrafficService(traffic *store.TrafficStore, settings *store.SettingsStore, docker *dockerutil.DockerClient, instances *store.InstanceStore) *TrafficService

NewTrafficService creates a new TrafficService.

func (*TrafficService) CheckExpirations

func (s *TrafficService) CheckExpirations(ctx context.Context)

CheckExpirations checks for secrets nearing or past expiry.

func (*TrafficService) CheckQuotas

func (s *TrafficService) CheckQuotas(ctx context.Context)

CheckQuotas auto-disables secrets that exceeded their quota and sends warnings at 80%.

func (*TrafficService) Flush

func (s *TrafficService) Flush(ctx context.Context) error

Flush computes deltas from the latest Prometheus snapshot and persists them.

func (*TrafficService) GetHistory added in v0.0.10

func (s *TrafficService) GetHistory(ctx context.Context, start, end int64, label string, aggregate string) ([]model.TrafficHistoryRecord, error)

GetHistory returns traffic history records for the given time range and label.

func (*TrafficService) GetLiveMetrics

func (s *TrafficService) GetLiveMetrics(ctx context.Context) (*model.LiveMetrics, error)

GetLiveMetrics fetches and caches live Prometheus metrics from all instances.

func (*TrafficService) GetReport

func (s *TrafficService) GetReport(ctx context.Context) (*model.TrafficReport, error)

GetReport returns cumulative global + per-user traffic.

func (*TrafficService) GetUserTraffic

func (s *TrafficService) GetUserTraffic(ctx context.Context, label string) (*model.UserTraffic, error)

GetUserTraffic returns traffic for a specific user.

func (*TrafficService) ResetAllQuotas added in v0.0.10

func (s *TrafficService) ResetAllQuotas(ctx context.Context)

ResetAllQuotas resets traffic counters for all users (monthly quota reset).

func (*TrafficService) SetSecretStore

func (s *TrafficService) SetSecretStore(secrets *store.SecretStore, quota *store.QuotaAlertStore)

SetSecretStore sets the secret store for quota enforcement.

type UpdateResult

type UpdateResult struct {
	PreviousVersion  string `json:"previous_version"`
	NewVersion       string `json:"new_version"`
	BinaryPath       string `json:"binary_path,omitempty"`
	BackupPath       string `json:"backup_path,omitempty"`
	ImagePulled      string `json:"image_pulled,omitempty"`
	WebImagePulled   string `json:"web_image_pulled,omitempty"`
	ContainerName    string `json:"container_name,omitempty"`
	WebContainerName string `json:"web_container_name,omitempty"`
	WebDistPath      string `json:"web_dist_path,omitempty"`
}

UpdateResult holds the outcome of an apply operation.

type UpdateService

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

UpdateService handles checking and applying self-updates.

func NewUpdateService

func NewUpdateService(dockerCli *dockerutil.DockerClient) *UpdateService

NewUpdateService creates a new UpdateService.

func (*UpdateService) Apply

func (s *UpdateService) Apply(ctx context.Context) (*UpdateResult, error)

Apply downloads and installs the update. In binary mode: downloads binary + web dist from GitHub releases. In Docker mode: pulls new images from GHCR.

func (*UpdateService) ApplyBinary added in v0.0.6

func (s *UpdateService) ApplyBinary(ctx context.Context) (*UpdateResult, error)

ApplyBinary downloads the latest release binary and replaces the running binary. Also downloads and extracts the web dist archive if available. The caller should trigger RestartSelf after sending the HTTP response.

func (*UpdateService) ApplyDocker added in v0.0.6

func (s *UpdateService) ApplyDocker(ctx context.Context) (*UpdateResult, error)

ApplyDocker pulls the new backend and web images.

func (*UpdateService) Check

func (s *UpdateService) Check(ctx context.Context) (*UpdateStatus, error)

Check queries the GitHub releases API for the latest version.

func (*UpdateService) RestartSelf

func (s *UpdateService) RestartSelf(newImage string) error

RestartSelf restarts the service. In binary mode: uses systemd. In Docker mode: spawns a sidecar container to recreate the container(s).

func (*UpdateService) RestartSelfDocker added in v0.0.6

func (s *UpdateService) RestartSelfDocker(newImage string) error

RestartSelfDocker creates a sidecar container to recreate the current container (and web container) with new images.

func (*UpdateService) Rollback

func (s *UpdateService) Rollback(backupPath string) error

Rollback restores the backup binary.

type UpdateStatus

type UpdateStatus struct {
	Current         string `json:"current"`
	Latest          string `json:"latest"`
	UpdateAvailable bool   `json:"update_available"`
	HTMLURL         string `json:"url,omitempty"`
	Mode            string `json:"mode"` // "docker" or "binary"
}

UpdateStatus holds the result of an update check.

type UpstreamService

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

UpstreamService handles upstream business logic.

func NewUpstreamService

func NewUpstreamService(upstreams *store.UpstreamStore) *UpstreamService

NewUpstreamService creates a new UpstreamService.

func (*UpstreamService) Add

Add creates a new upstream.

func (*UpstreamService) CheckAllUpstreams added in v0.0.10

func (s *UpstreamService) CheckAllUpstreams(ctx context.Context) error

CheckAllUpstreams iterates through all enabled upstreams and performs health checks.

func (*UpstreamService) Get

func (s *UpstreamService) Get(ctx context.Context, name string) (*model.Upstream, error)

Get returns a single upstream by name.

func (*UpstreamService) List

func (s *UpstreamService) List(ctx context.Context) ([]model.Upstream, error)

List returns all upstreams.

func (*UpstreamService) Remove

func (s *UpstreamService) Remove(ctx context.Context, name string) error

Remove deletes an upstream by name.

func (*UpstreamService) SetNotify added in v0.0.10

func (s *UpstreamService) SetNotify(fn NotifyFunc)

SetNotify sets the notification function.

func (*UpstreamService) Test

Test tests connectivity through an upstream and persists the result.

func (*UpstreamService) TestConfig added in v0.0.4

TestConfig tests connectivity using raw upstream data (no DB lookup).

func (*UpstreamService) Toggle

func (s *UpstreamService) Toggle(ctx context.Context, name string, enable bool) error

Toggle enables or disables an upstream.

func (*UpstreamService) Update added in v0.0.7

func (s *UpstreamService) Update(ctx context.Context, name string, u *model.Upstream) error

Update modifies an existing upstream.

Jump to

Keyboard shortcuts

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