mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-15 18:08:30 -07:00
Merge pull request #47 in DNS/adguard-dns from feature/349 to master
* commit '57ade2c3c3804d24857a45a8ab31c10534154dc7': Increase querylog size from 1000 to 10000 -- that'll use 32MB of memory. Web UI API -- Give out 24-hour stat instead of last 3 minutes.
This commit is contained in:
commit
b72d6f68e6
@ -6,7 +6,7 @@ import map from 'lodash/map';
|
|||||||
import Card from '../ui/Card';
|
import Card from '../ui/Card';
|
||||||
|
|
||||||
const Clients = props => (
|
const Clients = props => (
|
||||||
<Card title="Top blocked domains" subtitle="in the last 3 minutes" bodyType="card-table" refresh={props.refreshButton}>
|
<Card title="Top blocked domains" subtitle="in the last 24 hours" bodyType="card-table" refresh={props.refreshButton}>
|
||||||
<ReactTable
|
<ReactTable
|
||||||
data={map(props.topBlockedDomains, (value, prop) => (
|
data={map(props.topBlockedDomains, (value, prop) => (
|
||||||
{ ip: prop, domain: value }
|
{ ip: prop, domain: value }
|
||||||
|
@ -6,7 +6,7 @@ import map from 'lodash/map';
|
|||||||
import Card from '../ui/Card';
|
import Card from '../ui/Card';
|
||||||
|
|
||||||
const Clients = props => (
|
const Clients = props => (
|
||||||
<Card title="Top clients" subtitle="in the last 3 minutes" bodyType="card-table" refresh={props.refreshButton}>
|
<Card title="Top clients" subtitle="in the last 24 hours" bodyType="card-table" refresh={props.refreshButton}>
|
||||||
<ReactTable
|
<ReactTable
|
||||||
data={map(props.topClients, (value, prop) => (
|
data={map(props.topClients, (value, prop) => (
|
||||||
{ ip: prop, count: value }
|
{ ip: prop, count: value }
|
||||||
|
@ -5,13 +5,13 @@ import Card from '../ui/Card';
|
|||||||
import Tooltip from '../ui/Tooltip';
|
import Tooltip from '../ui/Tooltip';
|
||||||
|
|
||||||
const Counters = props => (
|
const Counters = props => (
|
||||||
<Card title="General statistics" subtitle="in the last 3 minutes" bodyType="card-table" refresh={props.refreshButton}>
|
<Card title="General statistics" subtitle="in the last 24 hours" bodyType="card-table" refresh={props.refreshButton}>
|
||||||
<table className="table card-table">
|
<table className="table card-table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
DNS Queries
|
DNS Queries
|
||||||
<Tooltip text="A number of DNS quieries processed in the last 3 minutes" />
|
<Tooltip text="A number of DNS quieries processed in the last 24 hours" />
|
||||||
</td>
|
</td>
|
||||||
<td className="text-right">
|
<td className="text-right">
|
||||||
<span className="text-muted">
|
<span className="text-muted">
|
||||||
|
@ -6,7 +6,7 @@ import map from 'lodash/map';
|
|||||||
import Card from '../ui/Card';
|
import Card from '../ui/Card';
|
||||||
|
|
||||||
const QueriedDomains = props => (
|
const QueriedDomains = props => (
|
||||||
<Card title="Top queried domains" subtitle="in the last 3 minutes" bodyType="card-table" refresh={props.refreshButton}>
|
<Card title="Top queried domains" subtitle="in the last 24 hours" bodyType="card-table" refresh={props.refreshButton}>
|
||||||
<ReactTable
|
<ReactTable
|
||||||
data={map(props.topQueriedDomains, (value, prop) => (
|
data={map(props.topQueriedDomains, (value, prop) => (
|
||||||
{ ip: prop, count: value }
|
{ ip: prop, count: value }
|
||||||
|
@ -217,7 +217,7 @@ func handleStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
// stats
|
// stats
|
||||||
// -----
|
// -----
|
||||||
func handleStats(w http.ResponseWriter, r *http.Request) {
|
func handleStats(w http.ResponseWriter, r *http.Request) {
|
||||||
histrical := generateMapFromStats(&statistics.perMinute, 0, 2)
|
histrical := generateMapFromStats(&statistics.perHour, 0, 24)
|
||||||
// sum them up
|
// sum them up
|
||||||
summed := map[string]interface{}{}
|
summed := map[string]interface{}{}
|
||||||
for key, values := range histrical {
|
for key, values := range histrical {
|
||||||
@ -231,7 +231,7 @@ func handleStats(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
summed[key] = summedValue
|
summed[key] = summedValue
|
||||||
}
|
}
|
||||||
summed["stats_period"] = "3 minutes"
|
summed["stats_period"] = "24 hours"
|
||||||
|
|
||||||
json, err := json.Marshal(summed)
|
json, err := json.Marshal(summed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -439,7 +439,7 @@ func handleStatsTop(w http.ResponseWriter, r *http.Request) {
|
|||||||
blocked := map[string]int{}
|
blocked := map[string]int{}
|
||||||
clients := map[string]int{}
|
clients := map[string]int{}
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
timeWindow := time.Minute * 3
|
timeWindow := time.Hour * 24
|
||||||
notBefore := now.Add(timeWindow * -1)
|
notBefore := now.Add(timeWindow * -1)
|
||||||
|
|
||||||
for _, value := range values {
|
for _, value := range values {
|
||||||
@ -494,7 +494,8 @@ func handleStatsTop(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
gen(&json, "top_queried_domains", domains, true)
|
gen(&json, "top_queried_domains", domains, true)
|
||||||
gen(&json, "top_blocked_domains", blocked, true)
|
gen(&json, "top_blocked_domains", blocked, true)
|
||||||
gen(&json, "top_clients", clients, false)
|
gen(&json, "top_clients", clients, true)
|
||||||
|
json.WriteString(" \"stats_period\": \"24 hours\"\n")
|
||||||
json.WriteString("}\n")
|
json.WriteString("}\n")
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
@ -16,6 +16,8 @@ import (
|
|||||||
"github.com/zfjagann/golang-ring"
|
"github.com/zfjagann/golang-ring"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const logBufferCap = 10000
|
||||||
|
|
||||||
var logBuffer = ring.Ring{}
|
var logBuffer = ring.Ring{}
|
||||||
|
|
||||||
type logEntry struct {
|
type logEntry struct {
|
||||||
@ -28,7 +30,7 @@ type logEntry struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
logBuffer.SetCapacity(1000)
|
logBuffer.SetCapacity(logBufferCap)
|
||||||
}
|
}
|
||||||
|
|
||||||
func logRequest(question *dns.Msg, answer *dns.Msg, result dnsfilter.Result, elapsed time.Duration, ip string) {
|
func logRequest(question *dns.Msg, answer *dns.Msg, result dnsfilter.Result, elapsed time.Duration, ip string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user