query_context

package
v5.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClientAddr

func GetClientAddr(qCtx *Context) (*netip.Addr, bool)

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.

func SetClientAddr

func SetClientAddr(qCtx *Context, addr *netip.Addr)

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 using NewContext. All Context funcs are not safe for concurrent use.

func NewContext

func NewContext(q *dns.Msg) *Context

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

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) 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. 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) SetMark

func (ctx *Context) SetMark(m uint32)

SetMark marks this Context with given mark.

func (*Context) SetResponse

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

SetResponse stores the response r to the context. Note: It just stores the pointer of r. So the caller MUST NOT 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) StoreValue

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

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

Jump to

Keyboard shortcuts

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