query_context

package
v5.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: GPL-3.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegKey

func RegKey() uint32

RegKey returns a unique uint32 for the key used in Context.StoreValue, Context.GetValue. It should only be called during initialization.

Types

type Context

type Context struct {

	// ServerMeta contains some meta info from the server.
	// It is read-only.
	ServerMeta ServerMeta
	// contains filtered or unexported fields
}

Context is a query context that pass through plugins. All Context funcs are not safe for concurrent use.

func NewContext

func NewContext(q *dns.Msg) *Context

NewContext creates a new query Context. q must have one question. NewContext takes the ownership of q.

func (*Context) ClientOpt added in v5.3.0

func (ctx *Context) ClientOpt() *dns.OPT

ClientOpt returns the OPT rr from client. Maybe nil, if client does not send it. Plugins that responsible for handling EDNS0 option should check ClientOpt and pick/add options into Q() on demand. The OPT is read-only.

func (*Context) Copy

func (ctx *Context) Copy() *Context

Copy deep copies this Context. See CopyTo.

func (*Context) CopyTo

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

CopyTo deep copies this Context to d. Note that values that stored by StoreValue is not deep-copied.

func (*Context) DeleteMark added in v5.1.1

func (ctx *Context) DeleteMark(m uint32)

DeleteMark deletes mark m from this Context.

func (*Context) DeleteValue added in v5.1.1

func (ctx *Context) DeleteValue(k uint32)

DeleteValue deletes value k from Context

func (*Context) GetValue

func (ctx *Context) GetValue(k uint32) (any, bool)

GetValue returns the value stored by StoreValue.

func (*Context) HasMark

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

HasMark reports whether this mark m was marked by SetMark.

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 contains a brief summary of this Context. Useful in log.

func (*Context) MarshalLogObject

func (ctx *Context) MarshalLogObject(encoder zapcore.ObjectEncoder) error

MarshalLogObject implements zapcore.ObjectMarshaler.

func (*Context) Q

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

Q returns the query msg that will be forward to upstream. It always returns a non-nil msg with one question and EDNS0 OPT. If Caller want to modify the msg, be sure not to break those conditions.

func (*Context) QOpt added in v5.3.0

func (ctx *Context) QOpt() *dns.OPT

QOpt returns the query opt. It always returns a non-nil opt. It's a helper func for searching opt in Q() manually.

func (*Context) QQuestion added in v5.3.0

func (ctx *Context) QQuestion() dns.Question

QQuestion returns the query question.

func (*Context) R

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

R returns the response that will be sent to client. It might be nil. Note: R does not have EDNS0. Caller MUST NOT add a dns.OPT into R. Use RespOpt() instead.

func (*Context) RespOpt added in v5.3.0

func (ctx *Context) RespOpt() *dns.OPT

RespOpt returns the OPT that will be sent to client. If client support EDNS0, then RespOpt always returns a non-nil OPT. No matter what R() returns. Otherwise, RespOpt returns nil.

func (*Context) SetMark

func (ctx *Context) SetMark(m uint32)

SetMark marks this Context with given mark.

func (*Context) SetResponse

func (ctx *Context) SetResponse(m *dns.Msg)

SetResponse sets m as response. It takes the ownership of m. If m is nil. It removes existing response.

func (*Context) StartTime

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

StartTime returns the time when the Context was created.

func (*Context) StoreValue

func (ctx *Context) StoreValue(k uint32, v any)

StoreValue stores any v in to this Context k MUST from RegKey.

func (*Context) UpstreamOpt added in v5.3.0

func (ctx *Context) UpstreamOpt() *dns.OPT

UpstreamOpt returns the OPT from upstream. May be nil. Plugins that responsible for handling EDNS0 option should check UpstreamOpt and pick/add options into RespOpt on demand. The OPT is read-only.

type ServerMeta added in v5.2.0

type ServerMeta = server.QueryMeta

Jump to

Keyboard shortcuts

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