database

package
v0.0.0-...-6bb147f Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The name of the database driver to use
	DBDriverName = "sqlite3"
	// The default limit on the number of queries returned from some database queries
	DefaultQueryTableLimit = 10
	/*
		The default location and name used by database commands to look for the Pi-Hole's
		FTL database file
	*/
	DefaultDatabaseFileLocation = "./pihole-FTL.db"
)

Database constants

Variables

This section is empty.

Functions

func ClientSummary

func ClientSummary(db *sql.DB)

Extracts a summary of all of the clients that have been served by the Pi-Hole instance.

NOTE: This will include duplicate DNS entries if the same client has been seen multiple times (i.e. a phone being seen as a LAN client both locally and via a VPN - the client itself is the same but has separate query counts and different local addresses and as such will be listed as many times as it has appeared in different contexts).

This database dump includes:

  • The client's address: (IP or mac addr)
  • The date that the client was first seen
  • The date that the last query from the client was received
  • The total number of queries received from the client
  • The client's DNS name

func Connect

func Connect(pathToPotentialDB string) *sql.DB

Attempts to connect to a database, returns an sql.DB handle if this connection succeeds

func FormattedDBUnixTimestamp

func FormattedDBUnixTimestamp(stamp int) string

Returns a RFC822 formatted version of a given Unix time integer retrieved from a database row. For example, given the Unix time of 1612548060, the function will return the string "05 Feb 21 18:01 GMT"

func NewConfiguredTabWriter

func NewConfiguredTabWriter(padding int) *tabwriter.Writer

Returns a newly configured tabwriter.Writer, with a parameterised padding, allowing optional changes to the padding between an element and the edge of its cell

func TopQueries

func TopQueries(db *sql.DB, limit int64, domainFilter string)

Extracts the the top queries of all time. This will include both blocked and non blocked queries. The only factor in ordering/appearance is the number of times that a query for that domain has hit the Pi-Hole.

An optional filter parameter can be provided that can filter down returned results to those belonging to a certain domain, or those that contain a certain word.

This query is also parameterised on a limit, the user can choose how many top queries they want returned (i.e. top 10, top 20 etc...).

This database dump includes:

  • The domain
  • The number of queries that have been sent for that domain
  • A total sum of all of the occurrences

Types

This section is empty.

Jump to

Keyboard shortcuts

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