diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..dafebcd --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2020 Eldwan Brianne <12190353+ebrianne@users.noreply.github.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/internal/adguard/client.go b/internal/adguard/client.go index 9ac7e95..eb3aafd 100644 --- a/internal/adguard/client.go +++ b/internal/adguard/client.go @@ -89,7 +89,7 @@ func (c *Client) getStatistics() *Stats { req, err := http.NewRequest("GET", statsURL, nil) if err != nil { - log.Fatal("An error has occured when creating HTTP statistics request ", err) + log.Fatal("An error has occurred when creating HTTP statistics request ", err) } if c.isUsingPassword() { @@ -98,7 +98,7 @@ func (c *Client) getStatistics() *Stats { resp, err := c.httpClient.Do(req) if err != nil { - log.Printf("An error has occured during login to Adguard: %v", err) + log.Printf("An error has occurred during login to Adguard: %v", err) } body, err := ioutil.ReadAll(resp.Body) diff --git a/internal/adguard/model.go b/internal/adguard/model.go index d935042..95f765d 100644 --- a/internal/adguard/model.go +++ b/internal/adguard/model.go @@ -2,10 +2,7 @@ package adguard import "fmt" -const ( - enabledStatus = "enabled" -) - +// Stats struct is the Adguard statistics JSON API corresponding model. type Stats struct { AvgProcessingTime float64 `json:"avg_processing_time"` DnsQueries int `json:"num_dns_queries"` diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index a13ecbc..ccd4700 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go @@ -7,6 +7,7 @@ import ( ) var ( + // AvgProcessingTime - Average processing time for a DNS query AvgProcessingTime = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "avg_processing_time", @@ -16,6 +17,7 @@ var ( []string{"hostname"}, ) + // DnsQueries - Number of DNS queries DnsQueries = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "num_dns_queries", @@ -25,6 +27,7 @@ var ( []string{"hostname"}, ) + // BlockedFiltering - Number of DNS queries blocked BlockedFiltering = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "num_blocked_filtering", @@ -34,6 +37,7 @@ var ( []string{"hostname"}, ) + // ParentalFiltering - Number of DNS queries replaced by parental control ParentalFiltering = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "num_replaced_parental", @@ -43,6 +47,7 @@ var ( []string{"hostname"}, ) + // SafeBrowsingFiltering - Number of DNS queries replaced by safe browsing SafeBrowsingFiltering = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "num_replaced_safebrowsing", @@ -52,6 +57,7 @@ var ( []string{"hostname"}, ) + // SafeSearchFiltering - Number of DNS queries replaced by safe search SafeSearchFiltering = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "num_replaced_safesearch", @@ -61,6 +67,7 @@ var ( []string{"hostname"}, ) + // TopQueries - The number of top queries TopQueries = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "top_queried_domains", @@ -70,6 +77,7 @@ var ( []string{"hostname", "domain"}, ) + // TopBlocked - The number of top domains blocked TopBlocked = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "top_blocked_domains", @@ -79,6 +87,7 @@ var ( []string{"hostname", "domain"}, ) + // TopClients - The number of top clients TopClients = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "top_clients",