wip: migrate to mono-repo. SPN has already been moved to spn/
This commit is contained in:
39
service/resolver/rr_context.go
Normal file
39
service/resolver/rr_context.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package resolver
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
// DNSRequestContext is a static structure to add information to DNS request connections.
|
||||
type DNSRequestContext struct {
|
||||
Domain string
|
||||
Question string
|
||||
RCode string
|
||||
|
||||
ServedFromCache bool
|
||||
RequestingNew bool
|
||||
IsBackup bool
|
||||
Filtered bool
|
||||
|
||||
Modified time.Time
|
||||
Expires time.Time
|
||||
}
|
||||
|
||||
// ToDNSRequestContext returns a new DNSRequestContext of the RRCache.
|
||||
func (rrCache *RRCache) ToDNSRequestContext() *DNSRequestContext {
|
||||
return &DNSRequestContext{
|
||||
Domain: rrCache.Domain,
|
||||
Question: rrCache.Question.String(),
|
||||
RCode: dns.RcodeToString[rrCache.RCode],
|
||||
|
||||
ServedFromCache: rrCache.ServedFromCache,
|
||||
RequestingNew: rrCache.RequestingNew,
|
||||
IsBackup: rrCache.IsBackup,
|
||||
Filtered: rrCache.Filtered,
|
||||
|
||||
Modified: time.Unix(rrCache.Modified, 0),
|
||||
Expires: time.Unix(rrCache.Expires, 0),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user