db

package
v0.0.0-...-3ee2cbc Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ByLastSeen = Sorting{
		Identifier:  "last_seen",
		DisplayName: "last seen",
		// contains filtered or unexported fields
	}
	ByNameFrequency = Sorting{
		Identifier:  "name_frequency",
		DisplayName: "name frequency",
		// contains filtered or unexported fields
	}
)

Functions

This section is empty.

Types

type Database

type Database struct {
	*sql.DB
	// contains filtered or unexported fields
}

func New

func New(path string) (*Database, error)

func (*Database) AddOrIgnoreSighting

func (db *Database) AddOrIgnoreSighting(name string, ip net.IP, serverID int64)

Adds an entry in the sightings table or does nothing if adding fails due to database constraints.

func (*Database) FindServerByDescription

func (db *Database) FindServerByDescription(desc string) []Server

func (*Database) GetServerID

func (db *Database) GetServerID(ip string, port int, description, mod string) (serverID int64)

Returns the ID of the server specified by IP and port. In case no such server exists, it is inserted and the rowid of the new entry is returned. If a server with that IP and port already exists but the description or mod changed, the entry is updated in the database.

func (*Database) Lookup

func (db *Database) Lookup(nameOrIP string, sorting Sorting, last90DaysOnly bool, directLookupForced bool) FinishedLookup

Looks up a name or an IP or IP range (IPs are assumed to be short forms of ranges).

func (*Database) Status

func (db *Database) Status() (status Status)

func (*Database) UpdateServerLastSeen

func (db *Database) UpdateServerLastSeen(serverID int64)

Updates the 'last seen' timestamp of a server.

type FinishedLookup

type FinishedLookup struct {
	Query                 string     `json:"query"`
	InterpretedAsName     bool       `json:"interpreted_as_name"`
	PerformedDirectLookup bool       `json:"direct"`
	Last90DaysOnly        bool       `json:"last_90_days_only"`
	Sorting               Sorting    `json:"sorting"`
	Results               []Sighting `json:"results"`
}

type Server

type Server struct {
	ID          int64  `json:"id"`
	IP          string `json:"ip"`
	Port        int    `json:"port"`
	Description string `json:"description"`
	Mod         string `json:"mod,omitempty"`
	LastSeen    int64  `json:"last_seen,omitempty"`
}

type Sighting

type Sighting struct {
	Name      string `json:"name"`
	IP        string `json:"ip"`
	Timestamp int64  `json:"time_seen"`
	Server    Server `json:"server"`
}

type Sorting

type Sorting struct {
	Identifier  string
	DisplayName string
	// contains filtered or unexported fields
}

func (Sorting) MarshalJSON

func (s Sorting) MarshalJSON() ([]byte, error)

type Status

type Status struct {
	NamesCount        int
	IPsCount          int
	CombinationsCount int
	SightingsCount    int
	ServersCount      int
}

Jump to

Keyboard shortcuts

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