forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
50 lines (41 loc) · 1.23 KB
/
errors.go
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
49
50
package dns
import (
"fmt"
)
// All dns protocol errors are defined here.
type Error interface {
error
ResponseError() string
}
type DNSError struct {
Err string
}
func (e *DNSError) Error() string {
if e == nil {
return "<nil>"
}
return e.Err
}
func (e *DNSError) ResponseError() string {
return "Response: " + e.Error()
}
// Common
var (
NonDnsMsg = &DNSError{Err: "Message's data could not be decoded as DNS"}
DuplicateQueryMsg = &DNSError{Err: "Another query with the same DNS ID from this client " +
"was received so this query was closed without receiving a response"}
NoResponse = &DNSError{Err: "No response to this query was received"}
OrphanedResponse = &DNSError{Err: "Response: received without an associated Query"}
)
// EDNS
var (
UdpPacketTooLarge = &DNSError{Err: fmt.Sprintf("Non-EDNS packet has size greater than %d", MaxDnsPacketSize)}
RespEdnsNoSupport = &DNSError{Err: "Responder does not support EDNS"}
RespEdnsUnexpected = &DNSError{Err: "Unexpected EDNS answer"}
)
// TCP
var (
ZeroLengthMsg = &DNSError{Err: "Message's length was set to zero"}
UnexpectedLengthMsg = &DNSError{Err: "Unexpected message data length"}
IncompleteMsg = &DNSError{Err: "Message's data is incomplete"}
)