Pointer for dnsfilter.Result in querylog didn't make things simpler, revert that change and all related changes.
This commit is contained in:
parent
2ba5cb48b2
commit
253d8a4016
|
@ -34,7 +34,7 @@ var (
|
||||||
type logEntry struct {
|
type logEntry struct {
|
||||||
Question []byte
|
Question []byte
|
||||||
Answer []byte `json:",omitempty"` // sometimes empty answers happen like binerdunt.top or rev2.globalrootservers.net
|
Answer []byte `json:",omitempty"` // sometimes empty answers happen like binerdunt.top or rev2.globalrootservers.net
|
||||||
Result *dnsfilter.Result
|
Result dnsfilter.Result
|
||||||
Time time.Time
|
Time time.Time
|
||||||
Elapsed time.Duration
|
Elapsed time.Duration
|
||||||
IP string
|
IP string
|
||||||
|
@ -61,11 +61,15 @@ func logRequest(question *dns.Msg, answer *dns.Msg, result *dnsfilter.Result, el
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if result == nil {
|
||||||
|
result = &dnsfilter.Result{}
|
||||||
|
}
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
entry := logEntry{
|
entry := logEntry{
|
||||||
Question: q,
|
Question: q,
|
||||||
Answer: a,
|
Answer: a,
|
||||||
Result: result,
|
Result: *result,
|
||||||
Time: now,
|
Time: now,
|
||||||
Elapsed: elapsed,
|
Elapsed: elapsed,
|
||||||
IP: ip,
|
IP: ip,
|
||||||
|
|
|
@ -168,7 +168,7 @@ func (r *dayTop) addEntry(entry *logEntry, q *dns.Msg, now time.Time) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if entry.Result != nil && entry.Result.IsFiltered {
|
if entry.Result.IsFiltered {
|
||||||
err := runningTop.hours[hour].incrementBlocked(hostname)
|
err := runningTop.hours[hour].incrementBlocked(hostname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to increment value: %s", err)
|
log.Printf("Failed to increment value: %s", err)
|
||||||
|
|
|
@ -193,27 +193,25 @@ func (h *histogram) Observe(value float64) {
|
||||||
// -----
|
// -----
|
||||||
func incrementCounters(entry *logEntry) {
|
func incrementCounters(entry *logEntry) {
|
||||||
requests.IncWithTime(entry.Time)
|
requests.IncWithTime(entry.Time)
|
||||||
if entry.Result != nil {
|
if entry.Result.IsFiltered {
|
||||||
if entry.Result.IsFiltered {
|
filtered.IncWithTime(entry.Time)
|
||||||
filtered.IncWithTime(entry.Time)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
switch entry.Result.Reason {
|
switch entry.Result.Reason {
|
||||||
case dnsfilter.NotFilteredWhiteList:
|
case dnsfilter.NotFilteredWhiteList:
|
||||||
whitelisted.IncWithTime(entry.Time)
|
whitelisted.IncWithTime(entry.Time)
|
||||||
case dnsfilter.NotFilteredError:
|
case dnsfilter.NotFilteredError:
|
||||||
errorsTotal.IncWithTime(entry.Time)
|
errorsTotal.IncWithTime(entry.Time)
|
||||||
case dnsfilter.FilteredBlackList:
|
case dnsfilter.FilteredBlackList:
|
||||||
filteredLists.IncWithTime(entry.Time)
|
filteredLists.IncWithTime(entry.Time)
|
||||||
case dnsfilter.FilteredSafeBrowsing:
|
case dnsfilter.FilteredSafeBrowsing:
|
||||||
filteredSafebrowsing.IncWithTime(entry.Time)
|
filteredSafebrowsing.IncWithTime(entry.Time)
|
||||||
case dnsfilter.FilteredParental:
|
case dnsfilter.FilteredParental:
|
||||||
filteredParental.IncWithTime(entry.Time)
|
filteredParental.IncWithTime(entry.Time)
|
||||||
case dnsfilter.FilteredInvalid:
|
case dnsfilter.FilteredInvalid:
|
||||||
// do nothing
|
// do nothing
|
||||||
case dnsfilter.FilteredSafeSearch:
|
case dnsfilter.FilteredSafeSearch:
|
||||||
safesearch.IncWithTime(entry.Time)
|
safesearch.IncWithTime(entry.Time)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
elapsedTime.ObserveWithTime(entry.Elapsed.Seconds(), entry.Time)
|
elapsedTime.ObserveWithTime(entry.Elapsed.Seconds(), entry.Time)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue