Documentation
¶
Index ¶
- func InstallSystemdService() error
- func IsDockerEnvironment() bool
- func IsSafeGitRef(ref string) bool
- func IsSystemdInstalled() bool
- func IsValidCountryCode(code string) bool
- func ReloadService() error
- func RestartService() error
- func UninstallSystemdService() error
- type BuildResult
- type ContainerService
- func (s *ContainerService) Reload(ctx context.Context) error
- func (s *ContainerService) Restart(ctx context.Context) error
- func (s *ContainerService) Start(ctx context.Context) error
- func (s *ContainerService) Status(ctx context.Context) (*model.ProxyStatus, error)
- func (s *ContainerService) Stop(ctx context.Context) error
- type DBTelemtConfig
- type DockerService
- type GeoblockService
- type HealthService
- type HealthStatus
- type OSType
- type ReplicationService
- func (s *ReplicationService) GenerateSSHKey(ctx context.Context) (string, error)
- func (s *ReplicationService) GetSSHPublicKey(ctx context.Context) (string, error)
- func (s *ReplicationService) SyncAll(ctx context.Context) []sshutil.SyncResult
- func (s *ReplicationService) SyncSlave(ctx context.Context, host string) (*sshutil.SyncResult, error)
- func (s *ReplicationService) TestSSH(ctx context.Context, host string) (*model.SlaveTestResult, error)
- type SecretService
- func (s *SecretService) Add(ctx context.Context, label, secretKey string) (*model.Secret, error)
- func (s *SecretService) Get(ctx context.Context, label string) (*model.Secret, error)
- func (s *SecretService) GetEnabledLabels(ctx context.Context) ([]string, error)
- func (s *SecretService) GetLink(ctx context.Context, label, serverIP string, port int, maskingEnabled bool, ...) (*model.SecretWithLink, error)
- func (s *SecretService) GetQRCode(ctx context.Context, label, serverIP string, port int, maskingEnabled bool, ...) ([]byte, error)
- func (s *SecretService) List(ctx context.Context) ([]model.Secret, error)
- func (s *SecretService) Remove(ctx context.Context, label string, force bool) error
- func (s *SecretService) ResetAllTraffic(ctx context.Context) error
- func (s *SecretService) ResetTraffic(ctx context.Context, label string) error
- func (s *SecretService) Rotate(ctx context.Context, label string) (*model.Secret, error)
- func (s *SecretService) SetLimits(ctx context.Context, label string, maxConns, maxIPs int, quotaBytes int64, ...) error
- func (s *SecretService) Toggle(ctx context.Context, label string, enable bool) error
- func (s *SecretService) UpdateNotes(ctx context.Context, label, notes string) error
- type SystemdServiceStatus
- type TelemtConfigProvider
- type TelemtReleaseInfo
- type TelemtReleaseListItem
- type TelemtUpdateService
- func (s *TelemtUpdateService) Apply(ctx context.Context, version, commit string) error
- func (s *TelemtUpdateService) CheckRemote(ctx context.Context) (*TelemtReleaseInfo, error)
- func (s *TelemtUpdateService) GetReleases(ctx context.Context) ([]TelemtReleaseListItem, error)
- func (s *TelemtUpdateService) GetStatus(ctx context.Context) (*TelemtUpdateStatus, error)
- func (s *TelemtUpdateService) ResetStaleUpdate(ctx context.Context)
- type TelemtUpdateStatus
- type TrafficService
- func (s *TrafficService) CheckExpirations(ctx context.Context)
- func (s *TrafficService) CheckQuotas(ctx context.Context)
- func (s *TrafficService) Flush(ctx context.Context) error
- func (s *TrafficService) GetLiveMetrics(ctx context.Context) (*model.LiveMetrics, error)
- func (s *TrafficService) GetReport(ctx context.Context) (*model.TrafficReport, error)
- func (s *TrafficService) GetUserTraffic(ctx context.Context, label string) (*model.UserTraffic, error)
- func (s *TrafficService) SetSecretStore(secrets *store.SecretStore, quota *store.QuotaAlertStore)
- type UpdateResult
- type UpdateService
- func (s *UpdateService) Apply(ctx context.Context) (*UpdateResult, error)
- func (s *UpdateService) ApplyBinary(ctx context.Context) (*UpdateResult, error)
- func (s *UpdateService) ApplyDocker(ctx context.Context) (*UpdateResult, error)
- func (s *UpdateService) Check(ctx context.Context) (*UpdateStatus, error)
- func (s *UpdateService) RestartSelf(newImage string) error
- func (s *UpdateService) RestartSelfDocker(newImage string) error
- func (s *UpdateService) Rollback(backupPath string) error
- type UpdateStatus
- type UpstreamService
- func (s *UpstreamService) Add(ctx context.Context, u *model.Upstream) error
- func (s *UpstreamService) Get(ctx context.Context, name string) (*model.Upstream, error)
- func (s *UpstreamService) List(ctx context.Context) ([]model.Upstream, error)
- func (s *UpstreamService) Remove(ctx context.Context, name string) error
- func (s *UpstreamService) Test(ctx context.Context, name string) (*model.UpstreamTestResult, error)
- func (s *UpstreamService) TestConfig(ctx context.Context, u *model.Upstream) (*model.UpstreamTestResult, error)
- func (s *UpstreamService) Toggle(ctx context.Context, name string, enable bool) error
- func (s *UpstreamService) Update(ctx context.Context, name string, u *model.Upstream) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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
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
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 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) Start ¶
func (s *ContainerService) Start(ctx context.Context) error
Start starts all enabled proxy instances.
func (*ContainerService) Status ¶
func (s *ContainerService) Status(ctx context.Context) (*model.ProxyStatus, error)
Status returns the current status of 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.
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 OSType ¶
type OSType struct {
Family string `json:"family"`
Version string `json:"version"`
Arch string `json:"arch"`
}
OSType represents the details of the host OS.
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 ¶
func (s *ReplicationService) SyncAll(ctx context.Context) []sshutil.SyncResult
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 ¶
func (s *ReplicationService) TestSSH(ctx context.Context, host string) (*model.SlaveTestResult, error)
TestSSH tests connectivity to a slave.
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 ¶
Add creates a new secret. If secretKey is empty, generates one automatically.
func (*SecretService) GetEnabledLabels ¶
func (s *SecretService) GetEnabledLabels(ctx context.Context) ([]string, error)
GetEnabledLabels returns labels of all enabled secrets.
func (*SecretService) GetLink ¶
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) 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 ¶
Rotate generates a new key for an existing secret, preserving the label and limits.
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) 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
func (s *TelemtUpdateService) GetReleases(ctx context.Context) ([]TelemtReleaseListItem, error)
GetReleases returns the cached releases list from the DB.
func (*TelemtUpdateService) GetStatus ¶ added in v0.0.7
func (s *TelemtUpdateService) GetStatus(ctx context.Context) (*TelemtUpdateStatus, error)
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.
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 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) 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) 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) Remove ¶
func (s *UpstreamService) Remove(ctx context.Context, name string) error
Remove deletes an upstream by name.
func (*UpstreamService) Test ¶
func (s *UpstreamService) Test(ctx context.Context, name string) (*model.UpstreamTestResult, error)
Test tests connectivity through an upstream.
func (*UpstreamService) TestConfig ¶ added in v0.0.4
func (s *UpstreamService) TestConfig(ctx context.Context, u *model.Upstream) (*model.UpstreamTestResult, error)
TestConfig tests connectivity using raw upstream data (no DB lookup).