*(dnsforward): fix reading in-memory entries

This commit is contained in:
Andrey Meshkov
2020-02-21 16:50:20 +03:00
parent 9d8a95f836
commit df427b6822
3 changed files with 11 additions and 7 deletions

View File

@@ -208,14 +208,17 @@ func (l *queryLog) getData(params getDataParams) map[string]interface{} {
memoryEntries := make([]*logEntry, 0)
// go through the buffer in the reverse order
// from NEWER to OLDER
for i := len(l.buffer) - 1; i >= 0; i-- {
entry := l.buffer[i]
if !matchesGetDataParams(entry, params) {
if entry.Time.UnixNano() >= params.OlderThan.UnixNano() {
// Ignore entries newer than what was requested
continue
}
if entry.Time.UnixNano() >= params.OlderThan.UnixNano() {
break
if !matchesGetDataParams(entry, params) {
continue
}
memoryEntries = append(memoryEntries, entry)