initdb

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBConfigInterface

type DBConfigInterface interface {
	GetDB() *sql.DB
	GetDBDir() string
	GetDBFilename() string
	GetDBPassword() string
	GetConfigName() string
	GetConfigPath() string
	GetLog() logger.LoggerInterface
}

type DBInitImpl

type DBInitImpl struct {
}

func (*DBInitImpl) NewInitDB

func (db *DBInitImpl) NewInitDB(dbDir string, dbFilename string, log logger.LoggerInterface) DBInterface

NewInitDB creates a new DB instance based on the provided parameters

type DBInitializer

type DBInitializer interface {
	NewInitDB(dbDir string, dbFilename string, log logger.LoggerInterface) DBInterface
}

type DBInterface

type DBInterface interface {
	Initialize(password string) (*sql.DB, error)
	CreateSaltTable(db *sql.DB) error
	StoreSalt(db SQLExecer, salt []byte, timestamp int64) error
	RetrieveSaltByTimestamp(db *sql.DB, timestamp int64) ([]byte, error)
	CreateTimestampIndex(db *sql.DB) error
	CheckEncrypted(dbDir string, dbFilename string) (bool, error)
}

type InitDB

type InitDB struct {
	DBDir      string
	DBFilename string
	Log        logger.LoggerInterface
}

func NewInitDB

func NewInitDB(DBDir string, DBFilename string, log logger.LoggerInterface) *InitDB

func (*InitDB) CheckEncrypted

func (i *InitDB) CheckEncrypted(dbDir string, dbName string) (bool, error)

func (*InitDB) CreateSaltTable

func (i *InitDB) CreateSaltTable(db *sql.DB) error

CreateSaltTable creates a table to store salts in the database.

func (*InitDB) CreateTimestampIndex

func (i *InitDB) CreateTimestampIndex(db *sql.DB) error

CreateTimestampIndex creates an index on the timestamp column to speed up queries.

func (*InitDB) InitializeDB

func (i *InitDB) InitializeDB(password string) (*sql.DB, error)

Initialize initializes the encrypted SQLite database.

func (*InitDB) RetrieveSalt

func (i *InitDB) RetrieveSalt(db *sql.DB, id int64) ([]byte, error)

RetrieveSalt fetches a salt by its ID.

func (*InitDB) RetrieveSaltByTimestamp

func (i *InitDB) RetrieveSaltByTimestamp(db *sql.DB, timestamp int64) ([]byte, error)

RetrieveSaltByTimestamp fetches a salt by its associated timestamp.

func (*InitDB) StoreSalt

func (i *InitDB) StoreSalt(db SQLExecer, saltValue []byte, manisfestGenerationTimestamp int64) (int64, error)

type RealDB

type RealDB struct {
	Init *InitDB
}

func (*RealDB) CheckEncrypted

func (db *RealDB) CheckEncrypted(dbDir, dbFilename string) (bool, error)

func (*RealDB) CreateSaltTable

func (db *RealDB) CreateSaltTable(database *sql.DB) error

func (*RealDB) CreateTimestampIndex

func (db *RealDB) CreateTimestampIndex(database *sql.DB) error

func (*RealDB) Initialize

func (db *RealDB) Initialize(password string) (*sql.DB, error)

Initialize maps to InitDB's Initialize

func (*RealDB) RetrieveSaltByTimestamp

func (db *RealDB) RetrieveSaltByTimestamp(database *sql.DB, timestamp int64) ([]byte, error)

RetrieveSaltByTimestamp maps to InitDB's RetrieveSaltByTimestamp

func (*RealDB) StoreSalt

func (db *RealDB) StoreSalt(database SQLExecer, salt []byte, timestamp int64) error

StoreSalt maps to InitDB's StoreSalt

type RealDBConfig

type RealDBConfig struct {
	Config *config.DBConfig
}

func (*RealDBConfig) GetConfigName

func (db *RealDBConfig) GetConfigName() string

func (*RealDBConfig) GetConfigPath

func (db *RealDBConfig) GetConfigPath() string

func (*RealDBConfig) GetDB

func (db *RealDBConfig) GetDB() *sql.DB

func (*RealDBConfig) GetDBDir

func (db *RealDBConfig) GetDBDir() string

func (*RealDBConfig) GetDBFilename

func (db *RealDBConfig) GetDBFilename() string

func (*RealDBConfig) GetDBPassword

func (db *RealDBConfig) GetDBPassword() string

func (*RealDBConfig) GetLog

func (db *RealDBConfig) GetLog() logger.LoggerInterface

type SQLExecer

type SQLExecer interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
}

Jump to

Keyboard shortcuts

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