dns

package
v0.0.0-...-f8c9d21 Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewARecord

func NewARecord(record *vinyl.Record) (*dns.A, error)

func NewResponse

func NewResponse(req *dns.Msg) *dns.Msg

NewResponse generates a response message based on a request message

func Start

func Start(server Server) error

Types

type DNSServer

type DNSServer struct {
	*dns.Server
}

func NewServer

func NewServer(handler dns.Handler, port int, protocol string) *DNSServer

type Handler

type Handler interface {
	ServeDNS(dns.ResponseWriter, *dns.Msg)
}

type RecordHandler

type RecordHandler struct {
	RecordStore RecordStorer
}

func NewRecordHandler

func NewRecordHandler(store RecordStorer) *RecordHandler

func (*RecordHandler) ParseQuestion

func (handler *RecordHandler) ParseQuestion(questions []dns.Question) ([]dns.RR, error)

ParseQuestion loops through questions and creates answers based on what is in the record store

func (*RecordHandler) ServeDNS

func (handler *RecordHandler) ServeDNS(w dns.ResponseWriter, request *dns.Msg)

ServeDNS implements interface for dns server handler

func (*RecordHandler) ServerErrorResponse

func (handler *RecordHandler) ServerErrorResponse(w dns.ResponseWriter, response *dns.Msg, err error)

ServerErrorResponse returns a server error and logs the error that caused it

type RecordStorer

type RecordStorer interface {
	GetRecord(string) (*vinyl.Record, error)
}

type ResponseWriter

type ResponseWriter interface {
	// LocalAddr returns the net.Addr of the server
	LocalAddr() net.Addr
	// RemoteAddr returns the net.Addr of the client that sent the current request.
	RemoteAddr() net.Addr
	// WriteMsg writes a reply back to the client.
	WriteMsg(*dns.Msg) error
	// Write writes a raw buffer back to the client.
	Write([]byte) (int, error)
	// Close closes the connection.
	Close() error
	// TsigStatus returns the status of the Tsig.
	TsigStatus() error
	// TsigTimersOnly sets the tsig timers only boolean.
	TsigTimersOnly(bool)
	// Hijack lets the caller take over the connection.
	// After a call to Hijack(), the DNS package will not do anything with the connection.
	Hijack()
}

type Server

type Server interface {
	ListenAndServe() error
}

type UnsupportedOpCodeError

type UnsupportedOpCodeError struct {
	Opcode int
}

func (*UnsupportedOpCodeError) Error

func (e *UnsupportedOpCodeError) Error() string

type UnsupportedRecordTypeError

type UnsupportedRecordTypeError struct {
	Type uint16
}

func (*UnsupportedRecordTypeError) Error

Jump to

Keyboard shortcuts

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