Documentation
¶
Index ¶
- Variables
- func RequestProtocolNames() []string
- func ResponseTypeNames() []string
- type Request
- type RequestProtocol
- type Response
- func NewEmptyResponse(request *Request, rcode int, rtype ResponseType, reason string) *Response
- func NewResponseWithAnswers(request *Request, answers []dns.RR, rtype ResponseType, reason string) *Response
- func NewResponseWithRcode(request *Request, rcode int, rtype ResponseType, reason string) *Response
- func NewResponseWithReason(request *Request, rtype ResponseType, reason string) *Response
- type ResponseType
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidRequestProtocol = fmt.Errorf("not a valid RequestProtocol, try [%s]", strings.Join(_RequestProtocolNames, ", "))
var ErrInvalidResponseType = fmt.Errorf("not a valid ResponseType, try [%s]", strings.Join(_ResponseTypeNames, ", "))
Functions ¶
func RequestProtocolNames ¶
func RequestProtocolNames() []string
RequestProtocolNames returns a list of possible string values of RequestProtocol.
func ResponseTypeNames ¶
func ResponseTypeNames() []string
ResponseTypeNames returns a list of possible string values of ResponseType.
Types ¶
type Request ¶
type Request struct {
ClientIP net.IP
RequestClientID string
Protocol RequestProtocol
ClientNames []string
Req *dns.Msg
RequestTS time.Time
}
Request represents client's DNS request
type RequestProtocol ¶
type RequestProtocol uint8
RequestProtocol represents the server protocol ENUM( TCP // is the TCP protocol UDP // is the UDP protocol )
const ( // RequestProtocolTCP is a RequestProtocol of type TCP. // is the TCP protocol RequestProtocolTCP RequestProtocol = iota // RequestProtocolUDP is a RequestProtocol of type UDP. // is the UDP protocol RequestProtocolUDP )
func ParseRequestProtocol ¶
func ParseRequestProtocol(name string) (RequestProtocol, error)
ParseRequestProtocol attempts to convert a string to a RequestProtocol.
func (*RequestProtocol) AppendText ¶ added in v0.28.0
func (x *RequestProtocol) AppendText(b []byte) ([]byte, error)
AppendText appends the textual representation of itself to the end of b (allocating a larger slice if necessary) and returns the updated slice.
Implementations must not retain b, nor mutate any bytes within b[:len(b)].
func (RequestProtocol) IsValid ¶
func (x RequestProtocol) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (RequestProtocol) MarshalText ¶
func (x RequestProtocol) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method.
func (RequestProtocol) String ¶
func (x RequestProtocol) String() string
String implements the Stringer interface.
func (*RequestProtocol) UnmarshalText ¶
func (x *RequestProtocol) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method.
type Response ¶
type Response struct {
Res *dns.Msg
Reason string
RType ResponseType
}
Response represents the response of a DNS query
func NewEmptyResponse ¶ added in v0.29.0
func NewEmptyResponse(request *Request, rcode int, rtype ResponseType, reason string) *Response
NewEmptyResponse creates a response with just the Rcode field set (no SetReply or SetRcode). This is used for minimal responses where only the return code matters.
func NewResponseWithAnswers ¶ added in v0.29.0
func NewResponseWithAnswers(request *Request, answers []dns.RR, rtype ResponseType, reason string) *Response
NewResponseWithAnswers creates a response with a DNS message that has SetReply called and the provided answer records added.
func NewResponseWithRcode ¶ added in v0.29.0
func NewResponseWithRcode(request *Request, rcode int, rtype ResponseType, reason string) *Response
NewResponseWithRcode creates a response with a specific return code using SetRcode. This is typically used for empty responses with specific error codes.
func NewResponseWithReason ¶ added in v0.29.0
func NewResponseWithReason(request *Request, rtype ResponseType, reason string) *Response
NewResponseWithReason creates a response with a DNS message that has SetReply called. This is used when you want to create a response that replies to the request, optionally with answer records.
type ResponseType ¶
type ResponseType int
ResponseType represents the type of the response ENUM( RESOLVED // the response was resolved by the external upstream resolver CACHED // the response was resolved from cache BLOCKED // the query was blocked CONDITIONAL // the query was resolved by the conditional upstream resolver CUSTOMDNS // the query was resolved by a custom rule HOSTSFILE // the query was resolved by looking up the hosts file FILTERED // the query was filtered by query type NOTFQDN // the query was filtered as it is not fqdn conform SPECIAL // the query was resolved by the special use domain name resolver SYNTHESIZED // the response was synthesized by DNS64 )
const ( // ResponseTypeRESOLVED is a ResponseType of type RESOLVED. // the response was resolved by the external upstream resolver ResponseTypeRESOLVED ResponseType = iota // ResponseTypeCACHED is a ResponseType of type CACHED. // the response was resolved from cache ResponseTypeCACHED // ResponseTypeBLOCKED is a ResponseType of type BLOCKED. // the query was blocked ResponseTypeBLOCKED // ResponseTypeCONDITIONAL is a ResponseType of type CONDITIONAL. // the query was resolved by the conditional upstream resolver ResponseTypeCONDITIONAL // ResponseTypeCUSTOMDNS is a ResponseType of type CUSTOMDNS. // the query was resolved by a custom rule ResponseTypeCUSTOMDNS // ResponseTypeHOSTSFILE is a ResponseType of type HOSTSFILE. // the query was resolved by looking up the hosts file ResponseTypeHOSTSFILE // ResponseTypeFILTERED is a ResponseType of type FILTERED. // the query was filtered by query type ResponseTypeFILTERED // ResponseTypeNOTFQDN is a ResponseType of type NOTFQDN. // the query was filtered as it is not fqdn conform ResponseTypeNOTFQDN // ResponseTypeSPECIAL is a ResponseType of type SPECIAL. // the query was resolved by the special use domain name resolver ResponseTypeSPECIAL // ResponseTypeSYNTHESIZED is a ResponseType of type SYNTHESIZED. // the response was synthesized by DNS64 ResponseTypeSYNTHESIZED )
func ParseResponseType ¶
func ParseResponseType(name string) (ResponseType, error)
ParseResponseType attempts to convert a string to a ResponseType.
func (*ResponseType) AppendText ¶ added in v0.28.0
func (x *ResponseType) AppendText(b []byte) ([]byte, error)
AppendText appends the textual representation of itself to the end of b (allocating a larger slice if necessary) and returns the updated slice.
Implementations must not retain b, nor mutate any bytes within b[:len(b)].
func (ResponseType) IsValid ¶
func (x ResponseType) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (ResponseType) MarshalText ¶
func (x ResponseType) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method.
func (ResponseType) String ¶
func (x ResponseType) String() string
String implements the Stringer interface.
func (ResponseType) ToExtendedErrorCode ¶
func (t ResponseType) ToExtendedErrorCode() uint16
func (*ResponseType) UnmarshalText ¶
func (x *ResponseType) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method.