client

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

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

Go to latest
Published: Oct 8, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTPClient  *http.Client
	URL         string
	WebPassword string
}

Client represents Pihole client.

func New

func New(config Configuration) *Client

func (*Client) ForwardDestinations

func (c *Client) ForwardDestinations() (*[]ForwardDestination, error)

ForwardDestinations does ?getForwardDestinations query. Returns number of queries that have been forwarded to the targets.

func (*Client) QueryTypes

func (c *Client) QueryTypes() (*QueryTypes, error)

QueryTypes does ?getQueryTypes query. Returns number of queries that the Pi-hole’s DNS server has processed.

func (*Client) SummaryRaw

func (c *Client) SummaryRaw() (*SummaryRaw, error)

SummaryRaw does ?summaryRaw query. Returns summary statistics.

func (*Client) TopClients

func (c *Client) TopClients(top int) (*[]TopClient, error)

TopClients does ?topClients query. Returns top sources.

func (*Client) TopItems

func (c *Client) TopItems(top int) (*TopItems, error)

TopItems does ?topItems query. Returns top domains and top advertisements.

func (*Client) Version

func (c *Client) Version() (int, error)

Version does ?version query. Returns API version.

type Configuration

type Configuration struct {
	Client      *http.Client
	URL         string
	WebPassword string
}

type ForwardDestination

type ForwardDestination struct {
	Name    string
	Percent float64
}

ForwardDestination represents forwarder queries statistics.

type Query

type Query string
const (
	QueryVersion                Query = "version"
	QuerySummaryRaw             Query = "summaryRaw"
	QueryTopItems               Query = "topItems"               // AUTH
	QueryTopClients             Query = "topClients"             // AUTH
	QueryGetForwardDestinations Query = "getForwardDestinations" // AUTH
	QueryGetQueryTypes          Query = "getQueryTypes"          // AUTH
)

func (Query) WithValue

func (q Query) WithValue(value string) Query

type QueryTypes

type QueryTypes struct {
	A    float64 `json:"A (IPv4)"`
	AAAA float64 `json:"AAAA (IPv6)"`
	ANY  float64
	SRV  float64
	SOA  float64
	PTR  float64
	TXT  float64
}

QueryTypes represents DNS queries processing statistics.

type SummaryRaw

type SummaryRaw struct {
	DomainsBeingBlocked int64   `json:"domains_being_blocked"`
	DNSQueriesToday     int64   `json:"dns_queries_today"`
	AdsBlockedToday     int64   `json:"ads_blocked_today"`
	AdsPercentageToday  float64 `json:"ads_percentage_today"`
	UniqueDomains       int64   `json:"unique_domains"`
	QueriesForwarded    int64   `json:"queries_forwarded"`
	QueriesCached       int64   `json:"queries_cached"`
	ClientsEverSeen     int64   `json:"clients_ever_seen"`
	UniqueClients       int64   `json:"unique_clients"`
	DNSQueriesAllTypes  int64   `json:"dns_queries_all_types"`
	ReplyNODATA         int64   `json:"reply_NODATA"`
	ReplyNXDOMAIN       int64   `json:"reply_NXDOMAIN"`
	ReplyCNAME          int64   `json:"reply_CNAME"`
	ReplyIP             int64   `json:"reply_IP"`
	PrivacyLevel        int64   `json:"privacy_level"`
	Status              string  `json:"status"`
	GravityLastUpdated  struct {
		FileExists bool `json:"file_exists"`
		Absolute   *int64
	} `json:"gravity_last_updated"`
}

SummaryRaw represents summary statistics int raw format (no number formatting applied).

type TopAdvertisement

type TopAdvertisement = TopQuery

TopAdvertisement represents TopAdvertisement.

type TopClient

type TopClient struct {
	Name     string
	Requests int64
}

TopClient represents represents queries per client (source) statistics.

type TopItems

type TopItems struct {
	TopQueries []TopQuery
	TopAds     []TopAdvertisement
}

TopItems represents top domains and top advertisements' statistics.

type TopQuery

type TopQuery struct {
	Name string
	Hits int64
}

TopQuery represents TopQuery.

Jump to

Keyboard shortcuts

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