query_context

package
v4.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocateMark

func AllocateMark() (uint, error)

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context is a query context that pass through plugins A Context will always have a non-nil Q. Context MUST be created by NewContext.

func NewContext

func NewContext(q *dns.Msg, meta *RequestMeta) *Context

NewContext creates a new query Context. q is the query dns msg. It cannot be nil, or NewContext will panic. meta can be nil.

func (*Context) AddMark

func (ctx *Context) AddMark(m uint)

AddMark adds mark m to this Context.

func (*Context) Copy

func (ctx *Context) Copy() *Context

Copy deep copies this Context.

func (*Context) CopyTo

func (ctx *Context) CopyTo(d *Context) *Context

CopyTo deep copies this Context to d.

func (*Context) HasMark

func (ctx *Context) HasMark(m uint) bool

HasMark reports whether this Context has mark m.

func (*Context) Id

func (ctx *Context) Id() uint32

Id returns the Context id. Note: This id is not the dns msg id. It's a unique uint32 growing with the number of query.

func (*Context) InfoField

func (ctx *Context) InfoField() zap.Field

InfoField returns a zap.Field. Just for convenience.

func (*Context) OriginalQuery

func (ctx *Context) OriginalQuery() *dns.Msg

OriginalQuery returns the copied original query msg a that created the Context. It always returns a non-nil msg. The returned msg SHOULD NOT be modified.

func (*Context) Q

func (ctx *Context) Q() *dns.Msg

Q returns the query msg. It always returns a non-nil msg.

func (*Context) R

func (ctx *Context) R() *dns.Msg

R returns the response. It might be nil.

func (*Context) ReqMeta

func (ctx *Context) ReqMeta() *RequestMeta

ReqMeta returns the request metadata. The returned *RequestMeta is a reference shared by all ReqMeta. Caller must not modify it.

func (*Context) SetResponse

func (ctx *Context) SetResponse(r *dns.Msg, status ContextStatus)

SetResponse stores the response r to the context. Note: It just stores the pointer of r. So the caller shouldn't modify or read r after the call.

func (*Context) StartTime

func (ctx *Context) StartTime() time.Time

StartTime returns the time when the Context was created.

func (*Context) Status

func (ctx *Context) Status() ContextStatus

Status returns the context status.

func (*Context) String

func (ctx *Context) String() string

String returns a short summery of its query.

type ContextStatus

type ContextStatus uint8
const (
	ContextStatusWaitingResponse ContextStatus = iota
	ContextStatusResponded
	ContextStatusServerFailed
	ContextStatusDropped
	ContextStatusRejected
)

func (ContextStatus) String

func (status ContextStatus) String() string

type RequestMeta

type RequestMeta struct {
	// ClientIP contains the client ip address.
	ClientIP net.IP

	// FromUDP indicates the request is from an udp socket.
	FromUDP bool
}

RequestMeta represents some metadata about the request.

Jump to

Keyboard shortcuts

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