model

package
v0.36.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidRequestProtocol = fmt.Errorf("not a valid RequestProtocol, try [%s]", strings.Join(_RequestProtocolNames, ", "))
View Source
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
	// ReasonLabel is a low-cardinality variant of Reason, used as a Prometheus
	// metric label. When empty, metrics fall back to Reason. Blocked responses
	// set this to the matched group names only (without the matched rule), to
	// keep the `reason` label bounded even with large deny lists.
	ReasonLabel string
	RType       ResponseType
}

Response represents the response of a DNS query

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 REBIND // the answer was blocked by the DNS rebinding protection BOGUS // the answer failed DNSSEC validation )

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
	// ResponseTypeREBIND is a ResponseType of type REBIND.
	// the answer was blocked by the DNS rebinding protection
	ResponseTypeREBIND
	// ResponseTypeBOGUS is a ResponseType of type BOGUS.
	// the answer failed DNSSEC validation
	ResponseTypeBOGUS
)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL