Documentation
¶
Index ¶
- func FormatBytes(b int64) string
- type Backup
- type BackupStore
- type GeoblockCacheStore
- type InstanceStore
- func (s *InstanceStore) Count(ctx context.Context) (int, error)
- func (s *InstanceStore) Create(ctx context.Context, inst *model.Instance) error
- func (s *InstanceStore) Delete(ctx context.Context, port int) error
- func (s *InstanceStore) EnsureDefaultInstance(ctx context.Context, proxyPort, metricsPort int) error
- func (s *InstanceStore) GetByPort(ctx context.Context, port int) (*model.Instance, error)
- func (s *InstanceStore) List(ctx context.Context) ([]model.Instance, error)
- type QuotaAlertStore
- type SecretStore
- func (s *SecretStore) Count(ctx context.Context) (int, error)
- func (s *SecretStore) CountEnabled(ctx context.Context) (int, error)
- func (s *SecretStore) Create(ctx context.Context, sec *model.Secret) error
- func (s *SecretStore) Delete(ctx context.Context, label string) error
- func (s *SecretStore) GetByLabel(ctx context.Context, label string) (*model.Secret, error)
- func (s *SecretStore) List(ctx context.Context) ([]model.Secret, error)
- func (s *SecretStore) ListEnabledLabels(ctx context.Context) ([]string, error)
- func (s *SecretStore) ResetAllTraffic(ctx context.Context) error
- func (s *SecretStore) ResetTraffic(ctx context.Context, label string) error
- func (s *SecretStore) Update(ctx context.Context, sec *model.Secret) error
- func (s *SecretStore) UpdateTraffic(ctx context.Context, label string, deltaIn, deltaOut int64) error
- type SettingsStore
- func (s *SettingsStore) Get(ctx context.Context, key string) (string, error)
- func (s *SettingsStore) GetAuthPasswordHash(ctx context.Context) (string, error)
- func (s *SettingsStore) GetJWTSecret(ctx context.Context) (string, error)
- func (s *SettingsStore) Load(ctx context.Context) (*model.Settings, error)
- func (s *SettingsStore) Save(ctx context.Context, updates map[string]string) error
- func (s *SettingsStore) SetAuthPasswordHash(ctx context.Context, hash string) error
- type SlaveStore
- func (s *SlaveStore) Create(ctx context.Context, sl *model.Slave) error
- func (s *SlaveStore) Delete(ctx context.Context, host string) error
- func (s *SlaveStore) GetByHost(ctx context.Context, host string) (*model.Slave, error)
- func (s *SlaveStore) List(ctx context.Context) ([]model.Slave, error)
- func (s *SlaveStore) UpdateStatus(ctx context.Context, host, status string, lastSync int64) error
- type TokenBlocklistStore
- type TrafficStore
- func (s *TrafficStore) FlushTraffic(ctx context.Context, global model.TrafficSnapshot, ...) error
- func (s *TrafficStore) GetGlobal(ctx context.Context) (*model.TrafficSnapshot, error)
- func (s *TrafficStore) GetUserSnapshot(ctx context.Context, label string) (snapIn, snapOut int64, err error)
- func (s *TrafficStore) GetUserTraffic(ctx context.Context, label string) (*model.UserTraffic, error)
- func (s *TrafficStore) ListUserTraffic(ctx context.Context) ([]model.UserTraffic, error)
- func (s *TrafficStore) ResetGlobal(ctx context.Context) error
- func (s *TrafficStore) UpdateGlobal(ctx context.Context, deltaIn, deltaOut, snapIn, snapOut int64) error
- func (s *TrafficStore) UpdateUserTraffic(ctx context.Context, label string, deltaIn, deltaOut, snapIn, snapOut int64) error
- type UpstreamStore
- func (s *UpstreamStore) Create(ctx context.Context, u *model.Upstream) error
- func (s *UpstreamStore) Delete(ctx context.Context, name string) error
- func (s *UpstreamStore) GetByName(ctx context.Context, name string) (*model.Upstream, error)
- func (s *UpstreamStore) List(ctx context.Context) ([]model.Upstream, error)
- func (s *UpstreamStore) UpdateEnabled(ctx context.Context, name string, enabled bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatBytes ¶
FormatBytes formats bytes into human-readable string.
Types ¶
type Backup ¶
type Backup struct {
Filename string `json:"filename"`
Size int64 `json:"size"`
CreatedAt string `json:"created_at"`
}
Backup represents a backup file record.
type BackupStore ¶
type BackupStore struct {
// contains filtered or unexported fields
}
BackupStore handles backup management (listing, creation, deletion). It works with the filesystem in the configured backups directory.
func NewBackupStore ¶
func NewBackupStore(baseDir string) *BackupStore
NewBackupStore creates a new BackupStore.
func (*BackupStore) Create ¶
func (s *BackupStore) Create() (Backup, error)
Create generates a new backup of the core application data.
func (*BackupStore) Delete ¶
func (s *BackupStore) Delete(filename string) error
Delete removes a backup file.
func (*BackupStore) GetPath ¶
func (s *BackupStore) GetPath(filename string) string
GetPath returns the full path to a backup file.
func (*BackupStore) List ¶
func (s *BackupStore) List() ([]Backup, error)
List returns all backup files, newest first.
func (*BackupStore) Restore ¶
func (s *BackupStore) Restore(filename string) error
Restore restores data from the specified backup file.
type GeoblockCacheStore ¶
type GeoblockCacheStore struct {
// contains filtered or unexported fields
}
GeoblockCacheStore handles geo-block CIDR cache tracking.
func NewGeoblockCacheStore ¶
func NewGeoblockCacheStore(db *sql.DB) *GeoblockCacheStore
NewGeoblockCacheStore creates a new GeoblockCacheStore.
type InstanceStore ¶
type InstanceStore struct {
// contains filtered or unexported fields
}
InstanceStore handles instance persistence.
func NewInstanceStore ¶
func NewInstanceStore(db *sql.DB) *InstanceStore
NewInstanceStore creates a new InstanceStore.
func (*InstanceStore) Count ¶ added in v0.0.2
func (s *InstanceStore) Count(ctx context.Context) (int, error)
Count returns the total number of instances.
func (*InstanceStore) Delete ¶
func (s *InstanceStore) Delete(ctx context.Context, port int) error
Delete removes an instance by port.
func (*InstanceStore) EnsureDefaultInstance ¶ added in v0.0.2
func (s *InstanceStore) EnsureDefaultInstance(ctx context.Context, proxyPort, metricsPort int) error
EnsureDefaultInstance checks if instances table is empty and seeds it from settings.
type QuotaAlertStore ¶
type QuotaAlertStore struct {
// contains filtered or unexported fields
}
QuotaAlertStore handles quota alert deduplication.
func NewQuotaAlertStore ¶
func NewQuotaAlertStore(db *sql.DB) *QuotaAlertStore
NewQuotaAlertStore creates a new QuotaAlertStore.
func (*QuotaAlertStore) ClearForLabel ¶
func (s *QuotaAlertStore) ClearForLabel(ctx context.Context, label string) error
ClearForLabel removes quota alerts when traffic is reset.
func (*QuotaAlertStore) MarkAlerted ¶
MarkAlerted records that a quota alert was sent.
func (*QuotaAlertStore) WasAlerted ¶
WasAlerted checks if a quota alert was already sent for this label+percent combo.
type SecretStore ¶
type SecretStore struct {
// contains filtered or unexported fields
}
SecretStore handles secret persistence in SQLite.
func NewSecretStore ¶
func NewSecretStore(db *sql.DB) *SecretStore
NewSecretStore creates a new SecretStore.
func (*SecretStore) Count ¶
func (s *SecretStore) Count(ctx context.Context) (int, error)
Count returns total number of secrets.
func (*SecretStore) CountEnabled ¶
func (s *SecretStore) CountEnabled(ctx context.Context) (int, error)
CountEnabled returns the count of enabled secrets.
func (*SecretStore) Delete ¶
func (s *SecretStore) Delete(ctx context.Context, label string) error
Delete removes a secret by label.
func (*SecretStore) GetByLabel ¶
GetByLabel returns a single secret by label.
func (*SecretStore) ListEnabledLabels ¶
func (s *SecretStore) ListEnabledLabels(ctx context.Context) ([]string, error)
ListEnabledLabels returns labels of all enabled secrets.
func (*SecretStore) ResetAllTraffic ¶
func (s *SecretStore) ResetAllTraffic(ctx context.Context) error
ResetAllTraffic clears traffic for all users.
func (*SecretStore) ResetTraffic ¶
func (s *SecretStore) ResetTraffic(ctx context.Context, label string) error
ResetTraffic clears traffic for a specific user.
func (*SecretStore) UpdateTraffic ¶
func (s *SecretStore) UpdateTraffic(ctx context.Context, label string, deltaIn, deltaOut int64) error
UpdateTraffic increments the traffic counter for a user.
type SettingsStore ¶
type SettingsStore struct {
// contains filtered or unexported fields
}
SettingsStore handles settings persistence.
func NewSettingsStore ¶
func NewSettingsStore(db *sql.DB) *SettingsStore
NewSettingsStore creates a new SettingsStore.
func (*SettingsStore) GetAuthPasswordHash ¶
func (s *SettingsStore) GetAuthPasswordHash(ctx context.Context) (string, error)
GetAuthPasswordHash returns the stored bcrypt password hash.
func (*SettingsStore) GetJWTSecret ¶
func (s *SettingsStore) GetJWTSecret(ctx context.Context) (string, error)
GetJWTSecret returns the JWT signing secret, generating one if empty.
func (*SettingsStore) SetAuthPasswordHash ¶
func (s *SettingsStore) SetAuthPasswordHash(ctx context.Context, hash string) error
SetAuthPasswordHash stores the bcrypt password hash.
type SlaveStore ¶
type SlaveStore struct {
// contains filtered or unexported fields
}
SlaveStore handles replication slave persistence.
func NewSlaveStore ¶
func NewSlaveStore(db *sql.DB) *SlaveStore
NewSlaveStore creates a new SlaveStore.
func (*SlaveStore) Delete ¶
func (s *SlaveStore) Delete(ctx context.Context, host string) error
Delete removes a slave by host.
func (*SlaveStore) UpdateStatus ¶
UpdateStatus updates a slave's sync status.
type TokenBlocklistStore ¶
type TokenBlocklistStore struct {
// contains filtered or unexported fields
}
TokenBlocklistStore handles JWT token revocation.
func NewTokenBlocklistStore ¶
func NewTokenBlocklistStore(db *sql.DB) *TokenBlocklistStore
NewTokenBlocklistStore creates a new TokenBlocklistStore.
type TrafficStore ¶
type TrafficStore struct {
// contains filtered or unexported fields
}
TrafficStore handles cumulative traffic persistence.
func NewTrafficStore ¶
func NewTrafficStore(db *sql.DB) *TrafficStore
NewTrafficStore creates a new TrafficStore.
func (*TrafficStore) FlushTraffic ¶
func (s *TrafficStore) FlushTraffic(ctx context.Context, global model.TrafficSnapshot, users map[string]model.TrafficSnapshot) error
FlushTraffic persists all traffic deltas in a single transaction.
func (*TrafficStore) GetGlobal ¶
func (s *TrafficStore) GetGlobal(ctx context.Context) (*model.TrafficSnapshot, error)
GetGlobal returns cumulative global traffic.
func (*TrafficStore) GetUserSnapshot ¶
func (s *TrafficStore) GetUserSnapshot(ctx context.Context, label string) (snapIn, snapOut int64, err error)
GetUserSnapshot returns the raw Prometheus snapshot for a user.
func (*TrafficStore) GetUserTraffic ¶
func (s *TrafficStore) GetUserTraffic(ctx context.Context, label string) (*model.UserTraffic, error)
GetUserTraffic returns traffic for a specific user.
func (*TrafficStore) ListUserTraffic ¶
func (s *TrafficStore) ListUserTraffic(ctx context.Context) ([]model.UserTraffic, error)
ListUserTraffic returns all per-user traffic stats.
func (*TrafficStore) ResetGlobal ¶
func (s *TrafficStore) ResetGlobal(ctx context.Context) error
ResetGlobal clears global traffic counters.
func (*TrafficStore) UpdateGlobal ¶
func (s *TrafficStore) UpdateGlobal(ctx context.Context, deltaIn, deltaOut, snapIn, snapOut int64) error
UpdateGlobal adds deltas to global traffic and updates the snapshot.
func (*TrafficStore) UpdateUserTraffic ¶
func (s *TrafficStore) UpdateUserTraffic(ctx context.Context, label string, deltaIn, deltaOut, snapIn, snapOut int64) error
UpdateUserTraffic adds deltas to a user's traffic and updates the snapshot.
type UpstreamStore ¶
type UpstreamStore struct {
// contains filtered or unexported fields
}
UpstreamStore handles upstream persistence.
func NewUpstreamStore ¶
func NewUpstreamStore(db *sql.DB) *UpstreamStore
NewUpstreamStore creates a new UpstreamStore.
func (*UpstreamStore) Delete ¶
func (s *UpstreamStore) Delete(ctx context.Context, name string) error
Delete removes an upstream by name.
func (*UpstreamStore) UpdateEnabled ¶
UpdateEnabled toggles an upstream's enabled state.