Documentation ¶
Index ¶
- func RegKey() uint32
- type Context
- func (ctx *Context) ClientOpt() *dns.OPT
- func (ctx *Context) Copy() *Context
- func (ctx *Context) CopyTo(d *Context) *Context
- func (ctx *Context) DeleteMark(m uint32)
- func (ctx *Context) DeleteValue(k uint32)
- func (ctx *Context) GetValue(k uint32) (any, bool)
- func (ctx *Context) HasMark(m uint32) bool
- func (ctx *Context) Id() uint32
- func (ctx *Context) InfoField() zap.Field
- func (ctx *Context) MarshalLogObject(encoder zapcore.ObjectEncoder) error
- func (ctx *Context) Q() *dns.Msg
- func (ctx *Context) QOpt() *dns.OPT
- func (ctx *Context) QQuestion() dns.Question
- func (ctx *Context) R() *dns.Msg
- func (ctx *Context) RespOpt() *dns.OPT
- func (ctx *Context) SetMark(m uint32)
- func (ctx *Context) SetResponse(m *dns.Msg)
- func (ctx *Context) StartTime() time.Time
- func (ctx *Context) StoreValue(k uint32, v any)
- func (ctx *Context) UpstreamOpt() *dns.OPT
- type ServerMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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
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) CopyTo ¶
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
DeleteMark deletes mark m from this Context.
func (*Context) DeleteValue ¶ added in v5.1.1
DeleteValue deletes value k from Context
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) InfoField ¶
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 ¶
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
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) R ¶
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
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) SetResponse ¶
SetResponse sets m as response. It takes the ownership of m. If m is nil. It removes existing response.
func (*Context) StoreValue ¶
StoreValue stores any v in to this Context k MUST from RegKey.
func (*Context) UpstreamOpt ¶ added in v5.3.0
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.