test

package
v0.0.0-...-a8fb01b Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func A

func A(rr string) *dns.A

func AAAA

func AAAA(rr string) *dns.AAAA

func CNAME

func CNAME(rr string) *dns.CNAME

func DNSKEY

func DNSKEY(rr string) *dns.DNSKEY
func Header(t *testing.T, tc Case, resp *dns.Msg) bool

func MX

func MX(rr string) *dns.MX

func NS

func NS(rr string) *dns.NS

func NSEC

func NSEC(rr string) *dns.NSEC

func OPT

func OPT(bufsize int, do bool) *dns.OPT

func PTR

func PTR(rr string) *dns.PTR

func RRSIG

func RRSIG(rr string) *dns.RRSIG

func SOA

func SOA(rr string) *dns.SOA

func SRV

func SRV(rr string) *dns.SRV

func Section

func Section(t *testing.T, tc Case, sect Sect, rr []dns.RR) bool

func TCPServer

func TCPServer(t *testing.T, laddr string) (*dns.Server, string, error)

func TXT

func TXT(rr string) *dns.TXT

func TempFile

func TempFile(t *testing.T, dir, content string) (string, func(), error)

TempFile will create a temporary file on disk and returns the name and a cleanup function to remove it later.

func UDPServer

func UDPServer(t *testing.T, laddr string) (*dns.Server, string, error)

Types

type Case

type Case struct {
	Qname  string
	Qtype  uint16
	Rcode  int
	Do     bool
	Answer []dns.RR
	Ns     []dns.RR
	Extra  []dns.RR
}

If the TTL of a record is 303 we don't care what the TTL is.

func (Case) Msg

func (c Case) Msg() *dns.Msg

type Handler

type Handler interface {
	ServeDNS(context.Context, dns.ResponseWriter, *dns.Msg) (int, error)
}

Copied here to prevent an import cycle, so that we can define to above handlers.

func ErrorHandler

func ErrorHandler() Handler

ErrorHanlder returns a Handler that returns ServerFailure error when called.

func NextHandler

func NextHandler(rcode int, err error) Handler

NextHandler returns a Handler that returns rcode and err.

type HandlerFunc

type HandlerFunc func(context.Context, dns.ResponseWriter, *dns.Msg) (int, error)

HandlerFunc is a convenience type like dns.HandlerFunc, except ServeDNS returns an rcode and an error.

func (HandlerFunc) ServeDNS

func (f HandlerFunc) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the Handler interface.

type RRSet

type RRSet []dns.RR

func (RRSet) Len

func (p RRSet) Len() int

func (RRSet) Less

func (p RRSet) Less(i, j int) bool

func (RRSet) Swap

func (p RRSet) Swap(i, j int)

type ResponseWriter

type ResponseWriter struct{}

ResponseWriter is useful for writing tests. It uses some fixed values for the client. The remote will always be 10.240.0.1 and port 40212. The local address is always 127.0.0.1 and port 53.

func (*ResponseWriter) Close

func (t *ResponseWriter) Close() error

func (*ResponseWriter) Hijack

func (t *ResponseWriter) Hijack()

func (*ResponseWriter) LocalAddr

func (t *ResponseWriter) LocalAddr() net.Addr

LocalAddr returns the local address, always 127.0.0.1:53 (UDP).

func (*ResponseWriter) RemoteAddr

func (t *ResponseWriter) RemoteAddr() net.Addr

RemoteAddr returns the remote address, always 10.240.0.1:40212 (UDP).

func (*ResponseWriter) TsigStatus

func (t *ResponseWriter) TsigStatus() error

func (*ResponseWriter) TsigTimersOnly

func (t *ResponseWriter) TsigTimersOnly(bool)

func (*ResponseWriter) Write

func (t *ResponseWriter) Write(buf []byte) (int, error)

func (*ResponseWriter) WriteMsg

func (t *ResponseWriter) WriteMsg(m *dns.Msg) error

type Sect

type Sect int
const (
	Answer Sect = iota
	Ns
	Extra
)

Jump to

Keyboard shortcuts

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