Use separate DNSRequestContext struct for adding DNS context to connections

This commit is contained in:
Daniel
2021-10-19 10:25:49 +02:00
parent 49767d4c4a
commit b9b33ed2b3
6 changed files with 59 additions and 42 deletions

View File

@@ -2,7 +2,6 @@ package resolver
import (
"context"
"encoding/json"
"fmt"
"net"
"time"
@@ -45,25 +44,6 @@ type RRCache struct {
Modified int64
}
func (rrCache *RRCache) MarshalJSON() ([]byte, error) {
var record = struct {
RRCache
Question string
RCode string
Modified time.Time
Expires time.Time
}{
RRCache: *rrCache,
Question: rrCache.Question.String(),
RCode: dns.RcodeToString[rrCache.RCode],
Modified: time.Unix(rrCache.Modified, 0),
Expires: time.Unix(rrCache.Expires, 0),
}
return json.Marshal(record)
}
// ID returns the ID of the RRCache consisting of the domain and question type.
func (rrCache *RRCache) ID() string {
return rrCache.Domain + rrCache.Question.String()