database

package
v0.0.0-...-e9ab6a4 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package database provides an interface to the underlying database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HostDB

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

HostDB is a wrapper around the database connection.

func OpenDB

func OpenDB(path string) (*HostDB, error)

OpenDB opens a new database connection.

func (*HostDB) Begin

func (db *HostDB) Begin() error

Begin starts a transaction

func (*HostDB) Close

func (db *HostDB) Close()

Close closes the database connection

func (*HostDB) Commit

func (db *HostDB) Commit() error

Commit finishes a transaction

func (*HostDB) HostAdd

func (db *HostDB) HostAdd(host *data.Host) error

HostAdd adds a new Host to the database.

func (*HostDB) HostExists

func (db *HostDB) HostExists(addr string) (bool, error)

HostExists checks if a Host with the given address already exists in the database.

func (*HostDB) HostGetByHostReport

func (db *HostDB) HostGetByHostReport() ([]data.HostWithPorts, error)

HostGetByHostReport bla

func (*HostDB) HostGetByID

func (db *HostDB) HostGetByID(id krylib.ID) (*data.Host, error)

HostGetByID loads a Host by its ID

func (*HostDB) HostGetCount

func (db *HostDB) HostGetCount() (int64, error)

HostGetCount returns the number of Hosts in the database.

func (*HostDB) HostGetRandom

func (db *HostDB) HostGetRandom(max int) ([]data.Host, error)

HostGetRandom fetches up to <max> randomly chosen hosts from the database.

func (*HostDB) PortAdd

func (db *HostDB) PortAdd(res *data.ScanResult) error

PortAdd adds a new scanned port to the database.

func (*HostDB) PortGetByHost

func (db *HostDB) PortGetByHost(hostID krylib.ID) ([]data.Port, error)

PortGetByHost loads all the scanned ports of a given Host.

func (*HostDB) PortGetOpen

func (db *HostDB) PortGetOpen() ([]data.ScanResult, error)

PortGetOpen loads a list of all open ports that were scanned

func (*HostDB) PortGetRecent

func (db *HostDB) PortGetRecent(ref time.Time) ([]data.ScanResult, error)

func (*HostDB) PortGetReplyCount

func (db *HostDB) PortGetReplyCount() (int64, error)

PortGetReplyCount returns the number of open ports found on the given Host

func (*HostDB) Rollback

func (db *HostDB) Rollback() error

Rollback aborts a transaction

func (*HostDB) XfrAdd

func (db *HostDB) XfrAdd(xfr *data.XFR) error

XfrAdd starts a new zone transfer

func (*HostDB) XfrFinish

func (db *HostDB) XfrFinish(xfr *data.XFR, status xfrstatus.XfrStatus) error

XfrFinish marks a zone transfer as finished.

func (*HostDB) XfrGetByZone

func (db *HostDB) XfrGetByZone(zone string) (*data.XFR, error)

XfrGetByZone fetches an Xfr by the zone's name.

type Pool

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

Pool is a pool of database connections

func NewPool

func NewPool(cnt int) (*Pool, error)

NewPool creates a Pool of database connections. The number of connections to use is given by the parameter cnt.

func (*Pool) Close

func (pool *Pool) Close() error

Close closes all open database connections currently in the pool and empties the pool. Any connections retrieved from the pool that are in use at the time Close is called are unaffected.

func (*Pool) Get

func (pool *Pool) Get() *HostDB

Get returns a DB connection from the pool. If the pool is empty, it waits for a connection to be returned.

func (*Pool) GetNoWait

func (pool *Pool) GetNoWait() (*HostDB, error)

GetNoWait returns a DB connection from the pool. If the pool is empty, it creates a new one.

func (*Pool) IsEmpty

func (pool *Pool) IsEmpty() bool

IsEmpty returns true if the pool is currently empty.

func (*Pool) Put

func (pool *Pool) Put(db *HostDB)

Put returns a DB connection to the pool.

Directories

Path Synopsis
Package query provides symbolic constants for the various database queries/operations.
Package query provides symbolic constants for the various database queries/operations.

Jump to

Keyboard shortcuts

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