2019-05-08 23:45:04 +02:00
|
|
|
package pihole
|
|
|
|
|
2019-05-09 21:11:31 +02:00
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
const (
|
|
|
|
enabledStatus = "enabled"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Stats struct is the PI-Hole statistics JSON API corresponding model.
|
2019-05-08 23:45:04 +02:00
|
|
|
type Stats struct {
|
2019-05-09 21:11:31 +02:00
|
|
|
DomainsBeingBlocked int `json:"domains_being_blocked"`
|
|
|
|
DNSQueriesToday int `json:"dns_queries_today"`
|
|
|
|
AdsBlockedToday int `json:"ads_blocked_today"`
|
|
|
|
AdsPercentageToday float64 `json:"ads_percentage_today"`
|
|
|
|
UniqueDomains int `json:"unique_domains"`
|
|
|
|
QueriesForwarded int `json:"queries_forwarded"`
|
|
|
|
QueriesCached int `json:"queries_cached"`
|
|
|
|
ClientsEverSeen int `json:"clients_ever_seen"`
|
|
|
|
UniqueClients int `json:"unique_clients"`
|
|
|
|
DNSQueriesAllTypes int `json:"dns_queries_all_types"`
|
2023-02-27 20:59:36 +01:00
|
|
|
ReplyUnknown int `json:"reply_UNKNOWN"`
|
2019-05-09 21:11:31 +02:00
|
|
|
ReplyNoData int `json:"reply_NODATA"`
|
|
|
|
ReplyNxDomain int `json:"reply_NXDOMAIN"`
|
|
|
|
ReplyCname int `json:"reply_CNAME"`
|
|
|
|
ReplyIP int `json:"reply_IP"`
|
2023-02-27 20:59:36 +01:00
|
|
|
ReplyDomain int `json:"reply_DOMAIN"`
|
|
|
|
ReplyRRName int `json:"reply_RRNAME"`
|
|
|
|
ReplyServFail int `json:"reply_SERVFAIL"`
|
|
|
|
ReplyRefused int `json:"reply_REFUSED"`
|
|
|
|
ReplyNotImp int `json:"reply_NOTIMP"`
|
|
|
|
ReplyOther int `json:"reply_OTHER"`
|
|
|
|
ReplyDNSSEC int `json:"reply_DNSSEC"`
|
|
|
|
ReplyNone int `json:"reply_NONE"`
|
|
|
|
ReplyBlob int `json:"reply_BLOB"`
|
2019-05-09 21:11:31 +02:00
|
|
|
TopQueries map[string]int `json:"top_queries"`
|
|
|
|
TopAds map[string]int `json:"top_ads"`
|
|
|
|
TopSources map[string]int `json:"top_sources"`
|
|
|
|
ForwardDestinations map[string]float64 `json:"forward_destinations"`
|
|
|
|
QueryTypes map[string]float64 `json:"querytypes"`
|
|
|
|
Status string `json:"status"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToString method returns a string of the current statistics struct.
|
2021-12-10 15:39:22 +01:00
|
|
|
func (s *Stats) String() string {
|
2019-05-09 21:11:31 +02:00
|
|
|
return fmt.Sprintf("%d ads blocked / %d total DNS queries", s.AdsBlockedToday, s.DNSQueriesAllTypes)
|
2019-05-08 23:45:04 +02:00
|
|
|
}
|