Documentation
¶
Overview ¶
Package db provides a database interface and implementations.
Index ¶
- type Database
- func NewInMemory(path string) (Database, error)
- func NewPostgres(host, port, user, password, database string, batchSize int) (Database, error)
- func NewPostgresWithSSL(host, port, user, password, database, sslMode, poolMode string, batchSize int) (Database, error)
- func NewSqlite(path string, batchSize int) (Database, error)
- type Memory
- func (m *Memory) Close() error
- func (m *Memory) Connect() error
- func (m *Memory) Create(value any) error
- func (m *Memory) Delete(id string) error
- func (m *Memory) Get(id string) (*model.Ipsw, error)
- func (m *Memory) GetDSC(uuid string) (*model.DyldSharedCache, error)
- func (m *Memory) GetDSCImage(uuid string, addr uint64) (*model.Macho, error)
- func (m *Memory) GetIPSW(version, build, device string) (*model.Ipsw, error)
- func (m *Memory) GetIpswByName(name string) (*model.Ipsw, error)
- func (m *Memory) GetMachO(uuid string) (*model.Macho, error)
- func (m *Memory) GetSymbol(uuid string, addr uint64) (*model.Symbol, error)
- func (m *Memory) GetSymbols(uuid string) ([]*model.Symbol, error)
- func (m *Memory) List(version string) ([]*model.Ipsw, error)
- func (m *Memory) Save(value any) error
- type Postgres
- func (p *Postgres) Close() error
- func (p *Postgres) Connect() (err error)
- func (p *Postgres) Create(value any) error
- func (p *Postgres) Delete(key string) error
- func (p *Postgres) Get(key string) (*model.Ipsw, error)
- func (p *Postgres) GetDB() *gorm.DB
- func (p *Postgres) GetDSC(uuid string) (*model.DyldSharedCache, error)
- func (p *Postgres) GetDSCImage(uuid string, address uint64) (*model.Macho, error)
- func (p *Postgres) GetIPSW(version, build, device string) (*model.Ipsw, error)
- func (p *Postgres) GetIpswByName(name string) (*model.Ipsw, error)
- func (p *Postgres) GetMachO(uuid string) (*model.Macho, error)
- func (p *Postgres) GetSymbol(uuid string, address uint64) (*model.Symbol, error)
- func (p *Postgres) GetSymbols(uuid string) ([]*model.Symbol, error)
- func (p *Postgres) Save(value any) error
- type Sqlite
- func (s *Sqlite) Close() error
- func (s *Sqlite) Connect() (err error)
- func (s *Sqlite) Create(value any) error
- func (s *Sqlite) Delete(key string) error
- func (s *Sqlite) Get(key string) (*model.Ipsw, error)
- func (s *Sqlite) GetDB() *gorm.DB
- func (s *Sqlite) GetDSC(uuid string) (*model.DyldSharedCache, error)
- func (s *Sqlite) GetDSCImage(uuid string, address uint64) (*model.Macho, error)
- func (s *Sqlite) GetIPSW(version, build, device string) (*model.Ipsw, error)
- func (s *Sqlite) GetIpswByName(name string) (*model.Ipsw, error)
- func (s *Sqlite) GetMachO(uuid string) (*model.Macho, error)
- func (s *Sqlite) GetSymbol(uuid string, address uint64) (*model.Symbol, error)
- func (s *Sqlite) GetSymbols(uuid string) ([]*model.Symbol, error)
- func (s *Sqlite) Save(value any) error
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 ¶
NewInMemory creates a new in-memory database.
func NewPostgres ¶
NewPostgres creates a new Postgres database.
type Memory ¶
Memory is a database that stores data in memory.
func (*Memory) Close ¶
Close closes the database. It returns ErrClosed if the database is already closed.
func (*Memory) Create ¶
Create creates a new entry in the database. It returns ErrAlreadyExists if the key already exists.
func (*Memory) Delete ¶
Delete removes the given key. It returns ErrNotFound if the key does not exist.
func (*Memory) Get ¶
Get returns the IPSW for the given key. It returns ErrNotFound if the key does not exist.
func (*Memory) GetDSCImage ¶
func (*Memory) GetIPSW ¶
GetIPSW returns the IPSW for the given version, build, and device. It returns ErrNotFound if the IPSW does not exist.
func (*Memory) GetIpswByName ¶
GetIpswByName returns the IPSW for the given name. It returns ErrNotFound if the key does not exist.
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 ¶
Close closes the database. It returns ErrClosed if the database is already closed.
func (*Postgres) Create ¶
Create creates a new entry in the database. It returns ErrAlreadyExists if the key already exists.
func (*Postgres) Delete ¶
Delete removes the given key. It returns ErrNotFound if the key does not exist.
func (*Postgres) Get ¶
Get returns the value for the given key. It returns ErrNotFound if the key does not exist.
func (*Postgres) GetDSCImage ¶
func (*Postgres) GetIpswByName ¶
Get returns the value for the given key. It returns ErrNotFound if the key does not exist.
type Sqlite ¶
Sqlite is a database that stores data in a sqlite database.
func (*Sqlite) Close ¶
Close closes the database. It returns ErrClosed if the database is already closed.
func (*Sqlite) Create ¶
Create creates a new entry in the database. It returns ErrAlreadyExists if the key already exists.
func (*Sqlite) Delete ¶
Delete removes the given key. It returns ErrNotFound if the key does not exist.
func (*Sqlite) Get ¶
Get returns the value for the given key. It returns ErrNotFound if the key does not exist.
func (*Sqlite) GetDSCImage ¶
func (*Sqlite) GetIpswByName ¶
GetIpswByName returns the IPSW for the given name. It returns ErrNotFound if the key does not exist.