query_context

package
v0.0.0-...-bbb319f Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolUDP   = "udp"
	ProtocolTCP   = "tcp"
	ProtocolTLS   = "tls"
	ProtocolQUIC  = "quic"
	ProtocolHTTP  = "http"
	ProtocolHTTPS = "https"
	ProtocolH2    = "h2"
	ProtocolH3    = "h3"
)

Variables

This section is empty.

Functions

func AllocateMark

func AllocateMark() (uint, error)

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) AddMark

func (ctx *Context) AddMark(m uint)

AddMark adds mark m to this Context.

func (*Context) Copy

func (ctx *Context) Copy() *Context

Copy deep copies this Context.

func (*Context) CopyTo

func (ctx *Context) CopyTo(d *Context) *Context

CopyTo deep copies this Context to d.

func (*Context) HasMark

func (ctx *Context) HasMark(m uint) bool

HasMark reports whether this Context has mark m.

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. Just for convenience.

func (*Context) OriginalQuery

func (ctx *Context) OriginalQuery() *dns.Msg

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

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 shouldn't 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) String

func (ctx *Context) String() string

String returns a short summery of its query.

type RequestMeta

type RequestMeta struct {
	// contains filtered or unexported fields
}

RequestMeta represents some metadata about the request.

func NewRequestMeta

func NewRequestMeta(addr netip.Addr) *RequestMeta

func (*RequestMeta) GetClientAddr

func (m *RequestMeta) GetClientAddr() netip.Addr

func (*RequestMeta) GetProtocol

func (m *RequestMeta) GetProtocol() string

func (*RequestMeta) GetServerName

func (m *RequestMeta) GetServerName() string

func (*RequestMeta) SetClientAddr

func (m *RequestMeta) SetClientAddr(addr netip.Addr)

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 (*RequestMeta) SetProtocol

func (m *RequestMeta) SetProtocol(protocol string)

func (*RequestMeta) SetServerName

func (m *RequestMeta) SetServerName(serverName string)

Jump to

Keyboard shortcuts

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