Documentation ¶
Index ¶
- Variables
- func NewHandlerFunc(requestTimeout time.Duration, h dns.HandlerFunc, opt ...Option) (dns.HandlerFunc, error)
- type Option
- type RespWriter
- func (rw *RespWriter) Close() error
- func (rw *RespWriter) Hijack()
- func (rw *RespWriter) LocalAddr() net.Addr
- func (rw *RespWriter) Logger() *slog.Logger
- func (rw *RespWriter) RemoteAddr() net.Addr
- func (rw *RespWriter) RequestContext() context.Context
- func (rw *RespWriter) SetLogger(logger *slog.Logger)
- func (rw *RespWriter) TsigStatus() error
- func (rw *RespWriter) TsigTimersOnly(b bool)
- func (rw *RespWriter) Underlying() dns.ResponseWriter
- func (rw *RespWriter) Write([]byte) (int, error)
- func (rw *RespWriter) WriteMsg(msg *dns.Msg) error
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidParameter = errors.New("invalid parameter")
Functions ¶
func NewHandlerFunc ¶
func NewHandlerFunc(requestTimeout time.Duration, h dns.HandlerFunc, opt ...Option) (dns.HandlerFunc, error)
NewHandlerFunc returns a new dns.HandlerFunc that wraps the given handler with a RespWriter. The returned handler will use the given logger and requestTimeout to create the RespWriter. Options supported: WithLogger
Types ¶
type Option ¶
type Option func(interface{})
Option defines a common functional options type which can be used in a variadic parameter pattern.
func WithLogger ¶
WithLogger allows you to specify an optional logger.
type RespWriter ¶
type RespWriter struct {
// contains filtered or unexported fields
}
RespWriter is a wrapper around dns.ResponseWriter that provides "base" capabilities for the wrapped writer. Among other things, this is useful for ensuring that the wrapped writer is not used after the context is canceled.
func NewRespWriter ¶
func NewRespWriter(ctx context.Context, w dns.ResponseWriter, opt ...Option) *RespWriter
NewRespWriter returns a new RespWriter that wraps the given dns.ResponseWriter.
func (*RespWriter) Close ¶
func (rw *RespWriter) Close() error
Close closes the underlying connection.
func (*RespWriter) Hijack ¶
func (rw *RespWriter) Hijack()
Hijack hijacks the underlying connection.
func (*RespWriter) LocalAddr ¶
func (rw *RespWriter) LocalAddr() net.Addr
LocalAddr returns the local address of the server.
func (*RespWriter) Logger ¶
func (rw *RespWriter) Logger() *slog.Logger
Logger returns the logger to use for logging during the request.
func (*RespWriter) RemoteAddr ¶
func (rw *RespWriter) RemoteAddr() net.Addr
RemoteAddr returns the remote address of the client.
func (*RespWriter) RequestContext ¶
func (rw *RespWriter) RequestContext() context.Context
RequestContext returns the context for the request.
func (*RespWriter) SetLogger ¶
func (rw *RespWriter) SetLogger(logger *slog.Logger)
SetLogger sets the logger to use for logging during the request which allows you to override the logger passed to NewRespWriter(...)
func (*RespWriter) TsigStatus ¶
func (rw *RespWriter) TsigStatus() error
TsigStatus returns the Tsig status of the message.
func (*RespWriter) TsigTimersOnly ¶
func (rw *RespWriter) TsigTimersOnly(b bool)
TsigTimersOnly sets the Tsig timers only flag on the message.
func (*RespWriter) Underlying ¶
func (rw *RespWriter) Underlying() dns.ResponseWriter
Underlying returns the underlying dns.ResponseWriter