Documentation ¶
Index ¶
- func AllocateMark() (uint, error)
- type Context
- func (ctx *Context) AddMark(m uint)
- func (ctx *Context) Copy() *Context
- func (ctx *Context) CopyTo(d *Context) *Context
- func (ctx *Context) HasMark(m uint) bool
- func (ctx *Context) Id() uint32
- func (ctx *Context) InfoField() zap.Field
- func (ctx *Context) OriginalQuery() *dns.Msg
- func (ctx *Context) Q() *dns.Msg
- func (ctx *Context) R() *dns.Msg
- func (ctx *Context) ReqMeta() *RequestMeta
- func (ctx *Context) SetResponse(r *dns.Msg)
- func (ctx *Context) StartTime() time.Time
- func (ctx *Context) String() string
- type RequestMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllocateMark ¶
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, 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) Id ¶
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) OriginalQuery ¶
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) ReqMeta ¶
func (ctx *Context) ReqMeta() *RequestMeta
ReqMeta returns the request metadata. It always returns a non-nil RequestMeta. The returned *RequestMeta is a reference shared by all ReqMeta. Caller must not modify it.
func (*Context) SetResponse ¶
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.
type RequestMeta ¶
type RequestMeta struct { // ClientAddr contains the client ip address. // It might be zero/invalid. ClientAddr netip.Addr // FromUDP indicates the request is from an udp socket. FromUDP bool }
RequestMeta represents some metadata about the request.