Documentation ¶
Index ¶
- func GetClientAddr(qCtx *Context) (*netip.Addr, bool)
- func RegKey() uint32
- func SetClientAddr(qCtx *Context, addr *netip.Addr)
- type Context
- func (ctx *Context) Copy() *Context
- func (ctx *Context) CopyTo(d *Context) *Context
- 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) R() *dns.Msg
- func (ctx *Context) SetMark(m uint32)
- func (ctx *Context) SetResponse(r *dns.Msg)
- func (ctx *Context) StartTime() time.Time
- func (ctx *Context) StoreValue(k uint32, v any)
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.
func SetClientAddr ¶
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 ¶
NewContext creates a new query Context. q is the query dns msg. It cannot be nil, or NewContext will panic.
func (*Context) CopyTo ¶
CopyTo deep copies this Context to d. Note that values that stored by StoreValue is not deep-copied.
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) SetResponse ¶
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) StoreValue ¶
StoreValue stores any v in to this Context k MUST from RegKey.