Pull request: querylog: resort buffers

Merge in DNS/adguard-home from 2293-log-sort to master

Updates #2293.

Squashed commit of the following:

commit f8961e5c52f82befe23ab1f7603a867243186498
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Sat Nov 28 17:19:15 2020 +0300

    all: document changes

commit c92c53307f1ed4a1c3196bdc19d23a775876b106
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Sat Nov 28 16:44:01 2020 +0300

    querylog: resort buffers
This commit is contained in:
Ainar Garipov
2020-11-30 13:32:58 +03:00
parent 60d72fb9c3
commit 6e615c6eaa
7 changed files with 91 additions and 7 deletions

View File

@@ -32,7 +32,7 @@ func (l *queryLog) getClientIP(clientIP string) string {
// entriesToJSON - converts log entries to JSON
func (l *queryLog) entriesToJSON(entries []*logEntry, oldest time.Time) map[string]interface{} {
// init the response object
var data = []map[string]interface{}{}
data := []map[string]interface{}{}
// the elements order is already reversed (from newer to older)
for i := 0; i < len(entries); i++ {
@@ -41,7 +41,7 @@ func (l *queryLog) entriesToJSON(entries []*logEntry, oldest time.Time) map[stri
data = append(data, jsonEntry)
}
var result = map[string]interface{}{}
result := map[string]interface{}{}
result["oldest"] = ""
if !oldest.IsZero() {
result["oldest"] = oldest.Format(time.RFC3339Nano)
@@ -123,7 +123,7 @@ func answerToMap(a *dns.Msg) []map[string]interface{} {
return nil
}
var answers = []map[string]interface{}{}
answers := []map[string]interface{}{}
for _, k := range a.Answer {
header := k.Header()
answer := map[string]interface{}{