-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathresponse.go
More file actions
48 lines (39 loc) · 751 Bytes
/
Copy pathresponse.go
File metadata and controls
48 lines (39 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package resolver
import (
"context"
"github.com/miekg/dns"
"github.com/nsmithuk/resolver/dnssec"
"time"
)
type Response struct {
Msg *dns.Msg
Err error
Duration time.Duration
Doe dnssec.DenialOfExistenceState
Auth dnssec.AuthenticationResult
}
func (r *Response) HasError() bool {
return r != nil && r.Err != nil
}
func (r *Response) IsEmpty() bool {
return r == nil || r.Msg == nil
}
func (r *Response) truncated() bool {
if r.IsEmpty() {
return false
}
return r.Msg.Truncated
}
func newResponseError(err error) *Response {
return &Response{
Err: err,
}
}
//---
type exchanger interface {
exchange(context.Context, *dns.Msg) *Response
}
type expiringExchanger interface {
exchanger
expired() bool
}