api

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: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllQueryDataKey = "data"
	// The starting setting for the number of queries that are included in the live log
	DefaultAmountOfQueries = 10
)
View Source
const (
	DNSQueriesTodayKey     = "dns_queries_today"
	AdsBlockedTodayKey     = "ads_blocked_today"
	PercentBlockedTodayKey = "ads_percentage_today"
	DomainsOnBlockListKey  = "domains_being_blocked"
	StatusKey              = "status"
	PrivacyLevelKey        = "privacy_level"
	TotalClientsSeenKey    = "clients_ever_seen"
)

Keys that can be used to index JSON responses from the Pi-Hole's API

View Source
const (
	TopQueriesTodayKey = "top_queries"
	TopAdsTodayKey     = "top_ads"
)

Keys that can be used to index JSON responses from the Pi-Hole's API

Variables

View Source
var LiveAllQueries = NewAllQueries()

instance of AllQueries used at runtime

View Source
var LiveSummary = NewSummary()
View Source
var LiveTopItems = NewTopItems()

Instance of TopItems used at runtime

Functions

func DisablePiHole

func DisablePiHole(timeout bool, time int64)

Disable the Pi-Hole

func EnablePiHole

func EnablePiHole()

Enable the Pi-Hole

Types

type AllQueries

type AllQueries struct {
	// Slice of Query structs
	Queries []Query
	// The amount of queries being stored in the log
	AmountOfQueriesInLog int
	// The queries stored in a format able to be displayed as a table
	Table []string
}

Holds a slice of query structs

func NewAllQueries

func NewAllQueries() *AllQueries

Make a new AllQueries instance

func (*AllQueries) Update

func (allQueries *AllQueries) Update(wg *sync.WaitGroup)

Updates the all queries list with up to date information from the Pi-Hole

type Query

type Query struct {
	// UNIX timestamp of when the query was logged
	UnixTime string
	// The type of query
	QueryType string
	// The domain the query was sent to
	Domain string
	// The client that sent the query
	OriginClient string
	// Where the query was forwarded to
	ForwardedTo string
}

Holds information about a single query logged by Pi-Hole

type Summary

type Summary struct {
	// Total number of queries logged today
	QueriesToday string
	// Total number of queries blocked today
	BlockedToday string
	// Percentage of today's queries that have been blocked
	PercentBlockedToday string
	// How large is Pi-Hole's active blocklist?
	DomainsOnBlocklist string
	// Enabled vs. disabled
	Status string
	// Pi-Hole's current data privacy level
	PrivacyLevel string
	// Mapping between privacy level numbers and their meanings
	PrivacyLevelNumberMapping map[string]string
	// The total number of clients that the Pi-Hole has seen
	TotalClientsSeen string
}

Summary holds things that do not require authentication to retrieve

func NewSummary

func NewSummary() *Summary

Returns a new Summary instance with default values for all fields

func (*Summary) Update

func (summary *Summary) Update(url string, key string, wg *sync.WaitGroup)

Updates a Summary struct with up to date information

type TopItems

type TopItems struct {
	// Mapping of top DNS queried domains and their occurrences
	TopQueries map[string]int
	// Mapping of top blocked DNS domains (ads and/or tracking) and their occurrences
	TopAds map[string]int
	// Pretty list version of TopQueries
	PrettyTopQueries []string
	// Pretty list version of TopAds
	PrettyTopAds []string
}

TopItems stores top permitted domains and top blocked domains (requires authentication to retrieve)

func NewTopItems

func NewTopItems() *TopItems

Create a new TopItems instance

func (*TopItems) Update

func (topItems *TopItems) Update(wg *sync.WaitGroup)

Updates a TopItems struct with up to date information

Jump to

Keyboard shortcuts

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