dnstest

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package dnstest allows for easy testing of DNS client against a test server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultiRecorder added in v1.0.2

type MultiRecorder struct {
	Len   int
	Msgs  []*dns.Msg
	Start time.Time
	dns.ResponseWriter
}

MultiRecorder is a type of ResponseWriter that captures all messages written to it.

func NewMultiRecorder added in v1.0.2

func NewMultiRecorder(w dns.ResponseWriter) *MultiRecorder

NewMultiRecorder makes and returns a new MultiRecorder.

func (*MultiRecorder) Write added in v1.0.2

func (r *MultiRecorder) Write(buf []byte) (int, error)

Write is a wrapper that records the length of the messages that get written to it.

func (*MultiRecorder) WriteMsg added in v1.0.2

func (r *MultiRecorder) WriteMsg(res *dns.Msg) error

WriteMsg records the message and its length written to it and call the underlying ResponseWriter's WriteMsg method.

type Recorder

type Recorder struct {
	dns.ResponseWriter
	Rcode int
	Len   int
	Msg   *dns.Msg
	Start time.Time
}

Recorder is a type of ResponseWriter that captures the rcode code written to it and also the size of the message written in the response. A rcode code does not have to be written, however, in which case 0 must be assumed. It is best to have the constructor initialize this type with that default status code.

func NewRecorder

func NewRecorder(w dns.ResponseWriter) *Recorder

NewRecorder makes and returns a new Recorder, which captures the DNS rcode from the ResponseWriter and also the length of the response message written through it.

func (*Recorder) Write

func (r *Recorder) Write(buf []byte) (int, error)

Write is a wrapper that records the length of the message that gets written.

func (*Recorder) WriteMsg

func (r *Recorder) WriteMsg(res *dns.Msg) error

WriteMsg records the status code and calls the underlying ResponseWriter's WriteMsg method.

type Server

type Server struct {
	Addr string // Address where the server listening.
	// contains filtered or unexported fields
}

A Server is an DNS server listening on a system-chosen port on the local loopback interface, for use in end-to-end DNS tests.

func NewServer

func NewServer(f dns.HandlerFunc) *Server

NewServer starts and returns a new Server. The caller should call Close when finished, to shut it down.

func (*Server) Close

func (s *Server) Close()

Close shuts down the server.

Jump to

Keyboard shortcuts

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