store

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDomainNotFound     = errors.New("domain not found")
	ErrDuplicateDomain    = errors.New("domain already registered")
	ErrAssignmentNotFound = errors.New("assignment not found")
)
View Source
var ErrAccountNotFound = errors.New("account not found")
View Source
var ErrChallengeNotFound = errors.New("acme challenge not found")
View Source
var ErrDeviceNotFound = errors.New("device not found")
View Source
var ErrDuplicateEK = errors.New("duplicate ek fingerprint")
View Source
var ErrDuplicateHostname = errors.New("hostname already taken")
View Source
var ErrDuplicateSlug = errors.New("duplicate slug")
View Source
var ErrNexusNotFound = errors.New("nexus instance not found")

Functions

func CreateDeviceWithAccount added in v0.1.1

func CreateDeviceWithAccount(ctx context.Context, pool *pgxpool.Pool, account *model.Account, device *model.Device) error

CreateDeviceWithAccount creates an account and a device in a single transaction.

Types

type ACMEStore

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

func NewACMEStore

func NewACMEStore(pool *pgxpool.Pool) *ACMEStore

func (*ACMEStore) Create

func (s *ACMEStore) Create(ctx context.Context, c *model.ACMEChallenge) error

func (*ACMEStore) Delete

func (s *ACMEStore) Delete(ctx context.Context, id uuid.UUID) error

func (*ACMEStore) GetByID

func (s *ACMEStore) GetByID(ctx context.Context, id uuid.UUID) (*model.ACMEChallenge, error)

func (*ACMEStore) GetExpired

func (s *ACMEStore) GetExpired(ctx context.Context) ([]*model.ACMEChallenge, error)

type AccountStore added in v0.1.1

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

func NewAccountStore added in v0.1.1

func NewAccountStore(pool *pgxpool.Pool) *AccountStore

func (*AccountStore) Create added in v0.1.1

func (s *AccountStore) Create(ctx context.Context, account *model.Account) error

func (*AccountStore) GetByID added in v0.1.1

func (s *AccountStore) GetByID(ctx context.Context, id uuid.UUID) (*model.Account, error)

type AuditStore

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

func NewAuditStore

func NewAuditStore(pool *pgxpool.Pool) *AuditStore

func (*AuditStore) DeleteOlderThan

func (s *AuditStore) DeleteOlderThan(ctx context.Context, days int) (int64, error)

func (*AuditStore) Log

func (s *AuditStore) Log(ctx context.Context, entry *model.AuditEntry) error

func (*AuditStore) LogAction

func (s *AuditStore) LogAction(ctx context.Context, actorType model.ActorType, actorID, action, resourceType string, resourceID *string, details any, ip net.IP)

type DeviceStore

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

func NewDeviceStore

func NewDeviceStore(pool *pgxpool.Pool) *DeviceStore

func (*DeviceStore) CleanupReleasedHostnames

func (s *DeviceStore) CleanupReleasedHostnames(ctx context.Context, maxAgeDays int) (int64, error)

func (*DeviceStore) Delete

func (s *DeviceStore) Delete(ctx context.Context, id uuid.UUID) error

func (*DeviceStore) GetByEKFingerprint

func (s *DeviceStore) GetByEKFingerprint(ctx context.Context, fingerprint string) (*model.Device, error)

func (*DeviceStore) GetByID

func (s *DeviceStore) GetByID(ctx context.Context, id uuid.UUID) (*model.Device, error)

func (*DeviceStore) GetBySlug added in v0.1.1

func (s *DeviceStore) GetBySlug(ctx context.Context, slug string) (*model.Device, error)

func (*DeviceStore) IsHostnameReleased

func (s *DeviceStore) IsHostnameReleased(ctx context.Context, label string, cooldownDays int) (bool, error)

func (*DeviceStore) IsLabelTaken

func (s *DeviceStore) IsLabelTaken(ctx context.Context, label string) (bool, error)

func (*DeviceStore) ReleaseHostname

func (s *DeviceStore) ReleaseHostname(ctx context.Context, label string, deviceID uuid.UUID) error

func (*DeviceStore) SetCustomHostname

func (s *DeviceStore) SetCustomHostname(ctx context.Context, p SetCustomHostnameParams) error

func (*DeviceStore) UpdateAKPublicKey

func (s *DeviceStore) UpdateAKPublicKey(ctx context.Context, id uuid.UUID, akPub []byte) error

func (*DeviceStore) UpdateLastSeen

func (s *DeviceStore) UpdateLastSeen(ctx context.Context, id uuid.UUID, ip net.IP) error

func (*DeviceStore) UpdateStatus

func (s *DeviceStore) UpdateStatus(ctx context.Context, id uuid.UUID, status model.DeviceStatus) error

type DomainStore added in v0.1.1

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

func NewDomainStore added in v0.1.1

func NewDomainStore(pool *pgxpool.Pool) *DomainStore

func (*DomainStore) AreDevicesInAccount added in v0.1.1

func (s *DomainStore) AreDevicesInAccount(ctx context.Context, accountID uuid.UUID, deviceIDs []uuid.UUID) (bool, error)

AreDevicesInAccount checks that all given device IDs belong to the specified account.

func (*DomainStore) AssignDevice added in v0.1.1

func (s *DomainStore) AssignDevice(ctx context.Context, domainID, deviceID uuid.UUID) error

AssignDevice assigns a domain to a device.

func (*DomainStore) CountByAccountID added in v0.1.1

func (s *DomainStore) CountByAccountID(ctx context.Context, accountID uuid.UUID) (int, error)

func (*DomainStore) Create added in v0.1.1

func (s *DomainStore) Create(ctx context.Context, d *model.AccountDomain) error

func (*DomainStore) Delete added in v0.1.1

func (s *DomainStore) Delete(ctx context.Context, id uuid.UUID) error

func (*DomainStore) DeleteExpiredPending added in v0.1.1

func (s *DomainStore) DeleteExpiredPending(ctx context.Context) (int64, error)

func (*DomainStore) GetByDomain added in v0.1.1

func (s *DomainStore) GetByDomain(ctx context.Context, domain string) (*model.AccountDomain, error)

func (*DomainStore) GetByID added in v0.1.1

func (s *DomainStore) GetByID(ctx context.Context, id uuid.UUID) (*model.AccountDomain, error)

func (*DomainStore) GetDeviceAliasDomains added in v0.1.1

func (s *DomainStore) GetDeviceAliasDomains(ctx context.Context, deviceID uuid.UUID) ([]string, error)

GetDeviceAliasDomains returns verified domain strings for a device.

func (*DomainStore) HasConflictingDomain added in v0.1.1

func (s *DomainStore) HasConflictingDomain(ctx context.Context, accountID uuid.UUID, domain string) (bool, error)

func (*DomainStore) ListAssignments added in v0.1.1

func (s *DomainStore) ListAssignments(ctx context.Context, domainID uuid.UUID) ([]*model.DomainAssignment, error)

ListAssignments returns all device assignments for a domain.

func (*DomainStore) ListByAccountID added in v0.1.1

func (s *DomainStore) ListByAccountID(ctx context.Context, accountID uuid.UUID) ([]*model.AccountDomain, error)

func (*DomainStore) UnassignDevice added in v0.1.1

func (s *DomainStore) UnassignDevice(ctx context.Context, domainID, deviceID uuid.UUID) error

UnassignDevice removes a device assignment from a domain.

func (*DomainStore) UpdateVerified added in v0.1.1

func (s *DomainStore) UpdateVerified(ctx context.Context, id uuid.UUID, verifiedByDeviceID uuid.UUID) error

type NexusStore

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

func NewNexusStore

func NewNexusStore(pool *pgxpool.Pool) *NexusStore

func (*NexusStore) GetByHostname

func (s *NexusStore) GetByHostname(ctx context.Context, hostname string) (*model.NexusInstance, error)

func (*NexusStore) ListActive

func (s *NexusStore) ListActive(ctx context.Context) ([]*model.NexusInstance, error)

func (*NexusStore) MarkInactive

func (s *NexusStore) MarkInactive(ctx context.Context, thresholdSeconds int) ([]uuid.UUID, error)

func (*NexusStore) UpdateResolvedAddresses

func (s *NexusStore) UpdateResolvedAddresses(ctx context.Context, id uuid.UUID, addrs []net.IP) error

func (*NexusStore) Upsert

func (s *NexusStore) Upsert(ctx context.Context, n *model.NexusInstance) error

type SetCustomHostnameParams

type SetCustomHostnameParams struct {
	DeviceID       uuid.UUID
	CustomHostname string
	ChangeCount    int
	HostnameYear   int
}

type Stores

type Stores struct {
	Device  *DeviceStore
	Nexus   *NexusStore
	ACME    *ACMEStore
	Audit   *AuditStore
	Account *AccountStore
	Domain  *DomainStore
}

func New

func New(pool *pgxpool.Pool) *Stores

Jump to

Keyboard shortcuts

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