database

package
v0.0.0-...-c08393c Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2017 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const HostTableName = "blacklistHosts"
View Source
const MetaTableName = "metadata"

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {

	// Initialize database connection
	Init(host string, port int) error

	// Insert new hosts into the database. Hosts are passed in via a chanel,
	// so this can be threaded with the function retrieving hosts from
	// the blacklist source
	InsertHosts(chan datatypes.BlacklistHost, string)

	// Remove a blacklist source from the database.
	RemoveHostList(hostlist.HostList, string)

	// Check a list of hosts against the database.
	FindHosts([]string, string) []datatypes.QueryResult

	// Retrieve meta data for a specific blacklist source.
	GetMetaData(hostlist.HostList, string) (hostlist.MetaData, error)

	// Register a new blacklist source with the database.
	RegisterHostList(hostlist.HostList, string) error
}

func NewMongoDb

func NewMongoDb() Database

Return a new mongo database instance.

type MongoDb

type MongoDb struct {
	Session *mgo.Session
}

func (*MongoDb) FindHosts

func (m *MongoDb) FindHosts(hosts []string, hostdb string) []datatypes.QueryResult

Query database for hosts. Return blacklist information

func (*MongoDb) GetMetaData

func (m *MongoDb) GetMetaData(hl hostlist.HostList, dbname string) (hostlist.MetaData, error)

Get metadata for a specific blacklist source

func (*MongoDb) Init

func (m *MongoDb) Init(host string, port int) error

Initialize this database connection

func (*MongoDb) InsertHosts

func (m *MongoDb) InsertHosts(c chan datatypes.BlacklistHost, hostdb string)

Insert new hosts into the database. Hosts are passed in via a chanel, so this can be threaded with the function retrieving hosts from the blacklist source

func (*MongoDb) RegisterHostList

func (m *MongoDb) RegisterHostList(hl hostlist.HostList, dbname string) error

Add a new source list to the metadata collection.

func (*MongoDb) RemoveHostList

func (m *MongoDb) RemoveHostList(hl hostlist.HostList, dbname string)

Remove a blacklist source from the database.

Jump to

Keyboard shortcuts

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