db

package
v0.0.0-prerelease Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package db provides a database interface and implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	// Connect connects to the database.
	Connect() error

	// Create creates a new entry in the database.
	// It returns gorm.ErrDuplicatedKey if the key already exists.
	Create(value any) error

	// Get returns the value for the given key.
	// It returns ErrNotFound if the key does not exist.
	Get(key string) (*model.Ipsw, error)

	// GetIpswByName returns the IPSW for the given name.
	// It returns ErrNotFound if the name does not exist.
	GetIpswByName(name string) (*model.Ipsw, error)

	// GetIPSW returns the IPSW for the given version, build, and device.
	// It returns ErrNotFound if the IPSW does not exist.
	GetIPSW(version, build, device string) (*model.Ipsw, error)

	// GetDSC returns the DyldSharedCache for the given UUID.
	GetDSC(uuid string) (*model.DyldSharedCache, error)

	// GetDSCImage returns the DyldSharedCache Image for the given UUID and address.
	GetDSCImage(uuid string, addr uint64) (*model.Macho, error)

	// GetMachO returns the MachO for the given UUID.
	GetMachO(uuid string) (*model.Macho, error)

	// GetSymbol returns the symbol for the given UUID and address.
	GetSymbol(uuid string, addr uint64) (*model.Symbol, error)

	// GetSymbols returns all symbols for the given UUID.
	GetSymbols(uuid string) ([]*model.Symbol, error)

	// Save updates the IPSW.
	// It overwrites any previous value for that IPSW.
	Save(value any) error

	// Delete removes the given key.
	// It returns ErrNotFound if the key does not exist.
	Delete(key string) error

	// Close closes the database.
	// It returns ErrClosed if the database is already closed.
	Close() error
}

Database is the interface that wraps the basic database operations.

func NewInMemory

func NewInMemory(path string) (Database, error)

NewInMemory creates a new in-memory database.

func NewPostgres

func NewPostgres(host, port, user, password, database string, batchSize int) (Database, error)

NewPostgres creates a new Postgres database.

func NewPostgresWithSSL

func NewPostgresWithSSL(host, port, user, password, database, sslMode, poolMode string, batchSize int) (Database, error)

NewPostgresWithSSL creates a new Postgres database with SSL configuration.

func NewSqlite

func NewSqlite(path string, batchSize int) (Database, error)

NewSqlite creates a new Sqlite database.

type Memory

type Memory struct {
	IPSWs map[string]*model.Ipsw
	Path  string
}

Memory is a database that stores data in memory.

func (*Memory) Close

func (m *Memory) Close() error

Close closes the database. It returns ErrClosed if the database is already closed.

func (*Memory) Connect

func (m *Memory) Connect() error

Connect connects to the database.

func (*Memory) Create

func (m *Memory) Create(value any) error

Create creates a new entry in the database. It returns ErrAlreadyExists if the key already exists.

func (*Memory) Delete

func (m *Memory) Delete(id string) error

Delete removes the given key. It returns ErrNotFound if the key does not exist.

func (*Memory) Get

func (m *Memory) Get(id string) (*model.Ipsw, error)

Get returns the IPSW for the given key. It returns ErrNotFound if the key does not exist.

func (*Memory) GetDSC

func (m *Memory) GetDSC(uuid string) (*model.DyldSharedCache, error)

func (*Memory) GetDSCImage

func (m *Memory) GetDSCImage(uuid string, addr uint64) (*model.Macho, error)

func (*Memory) GetIPSW

func (m *Memory) GetIPSW(version, build, device string) (*model.Ipsw, error)

GetIPSW returns the IPSW for the given version, build, and device. It returns ErrNotFound if the IPSW does not exist.

func (*Memory) GetIpswByName

func (m *Memory) GetIpswByName(name string) (*model.Ipsw, error)

GetIpswByName returns the IPSW for the given name. It returns ErrNotFound if the key does not exist.

func (*Memory) GetMachO

func (m *Memory) GetMachO(uuid string) (*model.Macho, error)

func (*Memory) GetSymbol

func (m *Memory) GetSymbol(uuid string, addr uint64) (*model.Symbol, error)

func (*Memory) GetSymbols

func (m *Memory) GetSymbols(uuid string) ([]*model.Symbol, error)

func (*Memory) List

func (m *Memory) List(version string) ([]*model.Ipsw, error)

func (*Memory) Save

func (m *Memory) Save(value any) error

Set sets the value for the given key. It overwrites any previous value for that key.

type Postgres

type Postgres struct {
	URL      string
	Host     string
	Port     string
	User     string
	Password string
	Database string
	SSLMode  string // SSL mode for connection (disable, require, verify-ca, verify-full)
	PoolMode string // Connection pool mode (session, transaction)
	// Config
	BatchSize int
	// contains filtered or unexported fields
}

Postgres is a database that stores data in a Postgres database.

func (*Postgres) Close

func (p *Postgres) Close() error

Close closes the database. It returns ErrClosed if the database is already closed.

func (*Postgres) Connect

func (p *Postgres) Connect() (err error)

Connect connects to the database.

func (*Postgres) Create

func (p *Postgres) Create(value any) error

Create creates a new entry in the database. It returns ErrAlreadyExists if the key already exists.

func (*Postgres) Delete

func (p *Postgres) Delete(key string) error

Delete removes the given key. It returns ErrNotFound if the key does not exist.

func (*Postgres) Get

func (p *Postgres) Get(key string) (*model.Ipsw, error)

Get returns the value for the given key. It returns ErrNotFound if the key does not exist.

func (*Postgres) GetDB

func (p *Postgres) GetDB() *gorm.DB

GetDB returns the underlying GORM database instance.

func (*Postgres) GetDSC

func (p *Postgres) GetDSC(uuid string) (*model.DyldSharedCache, error)

func (*Postgres) GetDSCImage

func (p *Postgres) GetDSCImage(uuid string, address uint64) (*model.Macho, error)

func (*Postgres) GetIPSW

func (p *Postgres) GetIPSW(version, build, device string) (*model.Ipsw, error)

func (*Postgres) GetIpswByName

func (p *Postgres) GetIpswByName(name string) (*model.Ipsw, error)

Get returns the value for the given key. It returns ErrNotFound if the key does not exist.

func (*Postgres) GetMachO

func (p *Postgres) GetMachO(uuid string) (*model.Macho, error)

func (*Postgres) GetSymbol

func (p *Postgres) GetSymbol(uuid string, address uint64) (*model.Symbol, error)

func (*Postgres) GetSymbols

func (p *Postgres) GetSymbols(uuid string) ([]*model.Symbol, error)

func (*Postgres) Save

func (p *Postgres) Save(value any) error

Save sets the value for the given key. It overwrites any previous value for that key.

type Sqlite

type Sqlite struct {
	URL string
	// Config
	BatchSize int
	// contains filtered or unexported fields
}

Sqlite is a database that stores data in a sqlite database.

func (*Sqlite) Close

func (s *Sqlite) Close() error

Close closes the database. It returns ErrClosed if the database is already closed.

func (*Sqlite) Connect

func (s *Sqlite) Connect() (err error)

Connect connects to the database.

func (*Sqlite) Create

func (s *Sqlite) Create(value any) error

Create creates a new entry in the database. It returns ErrAlreadyExists if the key already exists.

func (*Sqlite) Delete

func (s *Sqlite) Delete(key string) error

Delete removes the given key. It returns ErrNotFound if the key does not exist.

func (*Sqlite) Get

func (s *Sqlite) Get(key string) (*model.Ipsw, error)

Get returns the value for the given key. It returns ErrNotFound if the key does not exist.

func (*Sqlite) GetDB

func (s *Sqlite) GetDB() *gorm.DB

GetDB returns the underlying GORM database instance

func (*Sqlite) GetDSC

func (s *Sqlite) GetDSC(uuid string) (*model.DyldSharedCache, error)

func (*Sqlite) GetDSCImage

func (s *Sqlite) GetDSCImage(uuid string, address uint64) (*model.Macho, error)

func (*Sqlite) GetIPSW

func (s *Sqlite) GetIPSW(version, build, device string) (*model.Ipsw, error)

func (*Sqlite) GetIpswByName

func (s *Sqlite) GetIpswByName(name string) (*model.Ipsw, error)

GetIpswByName returns the IPSW for the given name. It returns ErrNotFound if the key does not exist.

func (*Sqlite) GetMachO

func (s *Sqlite) GetMachO(uuid string) (*model.Macho, error)

func (*Sqlite) GetSymbol

func (s *Sqlite) GetSymbol(uuid string, address uint64) (*model.Symbol, error)

func (*Sqlite) GetSymbols

func (s *Sqlite) GetSymbols(uuid string) ([]*model.Symbol, error)

func (*Sqlite) Save

func (s *Sqlite) Save(value any) error

Set sets the value for the given key. It overwrites any previous value for that key.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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