dns

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartServer

func StartServer(net, serverAddr string, h dns.Handler) *dns.Server

StartServer is a clone of the real code to start up a miekg DNS server.

Types

type AXFRResponse

type AXFRResponse struct {
	Rcode int
}

AXFRResponse is what is set with the AxfrServer to define what the response will be for its AXFR request.

type AxfrServer

type AxfrServer struct {
	Path string
	// contains filtered or unexported fields
}

AxfrServer is a mock server designed for a single DNS axfr request, a dumb server which loads the zone from a file and sends it back. It checks as little as possible to do the job.

func (*AxfrServer) GetResponse

func (t *AxfrServer) GetResponse() *AXFRResponse

GetResponse returns the current response as set

func (*AxfrServer) ServeDNS

func (t *AxfrServer) ServeDNS(wtr dns.ResponseWriter, q *dns.Msg)

ServeDNS meets the interface definition for dns.Handler

func (*AxfrServer) SetResponse

func (t *AxfrServer) SetResponse(r *AXFRResponse)

SetResponse sets a new response for the axfr query

type ExchangeResponse

type ExchangeResponse struct {
	Ignore    bool
	Truncated bool
	Rcode     int
	Ns        []dns.RR
	Answer    []dns.RR
	Extra     []dns.RR

	QueryCount int // Times mockDNSHandler served this mockExchangeResponse
}

ExchangeResponse is set by the caller to inform the ExchangeServer what the next response should contain.

type ExchangeServer

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

ExchangeServer is a mock replacement for a miekg dns.Handler. Used only for tests. It's a dumb server which does nothing more than copies the ExchangeResponse values into the reply message. It never checks the input or anything like that.

func (*ExchangeServer) GetResponse

func (t *ExchangeServer) GetResponse() *ExchangeResponse

GetResponse returns the current response as set

func (*ExchangeServer) ServeDNS

func (t *ExchangeServer) ServeDNS(wtr dns.ResponseWriter, q *dns.Msg)

ServeDNS meets the interface definition for dns.Handler

func (*ExchangeServer) SetResponse

func (t *ExchangeServer) SetResponse(r *ExchangeResponse)

SetResponse sets a new response for the next query

Jump to

Keyboard shortcuts

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