dnsforward -- fix panic on ANY request
This commit is contained in:
parent
c82a5ac0cb
commit
15f3c82238
|
@ -168,7 +168,7 @@ func (r *dayTop) addEntry(entry *logEntry, q *dns.Msg, now time.Time) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if entry.Result.IsFiltered {
|
if entry.Result != nil && 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,9 +193,11 @@ 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)
|
||||||
|
@ -212,6 +214,7 @@ func incrementCounters(entry *logEntry) {
|
||||||
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