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, status ContextStatus)
- func (ctx *Context) StartTime() time.Time
- func (ctx *Context) Status() ContextStatus
- func (ctx *Context) String() string
- type ContextStatus
- 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 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) 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. 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) Status ¶
func (ctx *Context) Status() ContextStatus
Status returns the context status.
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.