db

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DBPath

func DBPath() (string, error)

DBPath returns the path to the database file

func Delete

func Delete() error

Delete removes the database file (destructive).

func Exists

func Exists() (bool, error)

Exists checks if the database file exists

Types

type HostModel

type HostModel struct {
	ID            int
	Label         string
	Hostname      string
	Username      string
	Port          int
	KeyData       string // Encrypted blob
	KeyType       string
	CreatedAt     time.Time
	UpdatedAt     time.Time
	LastConnected *time.Time
}

HostModel mirrors the Host struct but for DB interactions

type MountState

type MountState struct {
	HostID     int
	LocalPath  string
	RemotePath string
	MountedAt  time.Time
}

type Store

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

Store handles database operations

func Init

func Init(password string) (*Store, error)

Init opens the database and initializes the schema. It derives the master key from the password and uses it for SQLCipher encryption.

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection

func (*Store) CreateHost

func (s *Store) CreateHost(h *HostModel, plainKey string) error

CreateHost adds a new host

func (*Store) CreateHostWithID

func (s *Store) CreateHostWithID(h *HostModel, encryptedKeyData string) error

CreateHostWithID creates a host with a specific ID (used for sync import). The keyData should already be encrypted.

func (*Store) DeleteAllMountStates

func (s *Store) DeleteAllMountStates() error

func (*Store) DeleteHost

func (s *Store) DeleteHost(id int) error

DeleteHost deletes a host

func (*Store) DeleteMountState

func (s *Store) DeleteMountState(hostID int) error

func (*Store) GetHostKey

func (s *Store) GetHostKey(id int) (string, error)

GetHostKey retrieves the decrypted private key for a host

func (*Store) GetHosts

func (s *Store) GetHosts() ([]HostModel, error)

GetHosts returns all hosts

func (*Store) GetMountStates

func (s *Store) GetMountStates() ([]MountState, error)

func (*Store) GetSalt

func (s *Store) GetSalt() (string, error)

GetSalt returns the encryption salt for this database (hex encoded)

func (*Store) ReencryptKeyData

func (s *Store) ReencryptKeyData(encryptedData string, sourceSaltHex string, password string) (string, error)

ReencryptKeyData decrypts key data using a source salt and re-encrypts with local salt. This is used during sync import when the source database had a different salt.

func (*Store) UpdateHost

func (s *Store) UpdateHost(h *HostModel) error

UpdateHost updates a host's metadata (without changing the key)

func (*Store) UpdateHostFromSync

func (s *Store) UpdateHostFromSync(h *HostModel, encryptedKeyData string, updatedAt time.Time) error

UpdateHostFromSync updates a host with sync data, preserving exact timestamps. The keyData should already be encrypted.

func (*Store) UpdateHostWithKey

func (s *Store) UpdateHostWithKey(h *HostModel, plainKey string) error

UpdateHostWithKey updates a host including the encrypted key data

func (*Store) UpdateLastConnected

func (s *Store) UpdateLastConnected(id int) error

UpdateLastConnected updates the last_connected timestamp for a host

func (*Store) UpsertMountState

func (s *Store) UpsertMountState(hostID int, localPath, remotePath string) error

Jump to

Keyboard shortcuts

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