request

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2018 License: Apache-2.0 Imports: 5 Imported by: 2,855

Documentation

Overview

Package request abstracts a client's request so that all plugins will handle them in an unified way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Proto

func Proto(w dns.ResponseWriter) string

Proto gets the protocol used as the transport. This will be udp or tcp.

Types

type Request

type Request struct {
	Req *dns.Msg
	W   dns.ResponseWriter

	// Optional lowercased zone of this query.
	Zone string

	Context context.Context
	// contains filtered or unexported fields
}

Request contains some connection state and is useful in plugin.

func (*Request) Class

func (r *Request) Class() string

Class returns the class of the question in the request. If the request is malformed the empty string is returned.

func (*Request) Clear

func (r *Request) Clear()

Clear clears all caching from Request s.

func (*Request) Do

func (r *Request) Do() bool

Do returns if the request has the DO (DNSSEC OK) bit set.

func (*Request) ErrorMessage

func (r *Request) ErrorMessage(rcode int) *dns.Msg

ErrorMessage returns an error message suitable for sending back to the client.

func (*Request) Family

func (r *Request) Family() int

Family returns the family of the transport, 1 for IPv4 and 2 for IPv6.

func (*Request) IP

func (r *Request) IP() string

IP gets the (remote) IP address of the client making the request.

func (*Request) Len

func (r *Request) Len() int

Len returns the length in bytes in the request.

func (*Request) LocalAddr added in v1.2.0

func (r *Request) LocalAddr() string

LocalAddr returns the net.Addr of the server handling the current request.

func (*Request) LocalIP added in v1.2.0

func (r *Request) LocalIP() string

LocalIP gets the (local) IP address of server handling the request.

func (*Request) LocalPort added in v1.2.0

func (r *Request) LocalPort() string

LocalPort gets the local port of the server handling the request.

func (*Request) Match added in v1.1.1

func (r *Request) Match(reply *dns.Msg) bool

Match checks if the reply matches the qname and qtype from the request, it returns false when they don't match.

func (*Request) Name

func (r *Request) Name() string

Name returns the name of the question in the request. Note this name will always have a closing dot and will be lower cased. After a call Name the value will be cached. To clear this caching call Clear. If the request is malformed the root zone is returned.

func (*Request) NewWithQuestion

func (r *Request) NewWithQuestion(name string, typ uint16) Request

NewWithQuestion returns a new request based on the old, but with a new question section in the request.

func (*Request) Port

func (r *Request) Port() string

Port gets the (remote) port of the client making the request.

func (*Request) Proto

func (r *Request) Proto() string

Proto gets the protocol used as the transport. This will be udp or tcp.

func (*Request) QClass

func (r *Request) QClass() uint16

QClass returns the class of the question in the request. If the request is malformed 0 returned.

func (*Request) QName

func (r *Request) QName() string

QName returns the name of the question in the request. If the request is malformed the root zone is returned.

func (*Request) QType

func (r *Request) QType() uint16

QType returns the type of the question as an uint16. If the request is malformed 0 is returned.

func (*Request) RemoteAddr

func (r *Request) RemoteAddr() string

RemoteAddr returns the net.Addr of the client that sent the current request.

func (*Request) Scrub

func (r *Request) Scrub(reply *dns.Msg) (*dns.Msg, int)

Scrub is a noop function, added for backwards compatibility reasons. The original Scrub is now called automatically by the server on writing the reply. See ScrubWriter.

func (*Request) Size

func (r *Request) Size() int

Size returns if buffer size *advertised* in the requests OPT record. Or when the request was over TCP, we return the maximum allowed size of 64K.

func (*Request) SizeAndDo

func (r *Request) SizeAndDo(m *dns.Msg) bool

SizeAndDo adds an OPT record that the reflects the intent from request. The returned bool indicated if an record was found and normalised.

func (*Request) Type

func (r *Request) Type() string

Type returns the type of the question as a string. If the request is malformed the empty string is returned.

type ScrubWriter added in v1.2.3

type ScrubWriter struct {
	dns.ResponseWriter
	// contains filtered or unexported fields
}

ScrubWriter will, when writing the message, call scrub to make it fit the client's buffer.

func NewScrubWriter added in v1.2.3

func NewScrubWriter(req *dns.Msg, w dns.ResponseWriter) *ScrubWriter

NewScrubWriter returns a new and initialized ScrubWriter.

func (*ScrubWriter) WriteMsg added in v1.2.3

func (s *ScrubWriter) WriteMsg(m *dns.Msg) error

WriteMsg overrides the default implementation of the underlaying dns.ResponseWriter and calls scrub on the message m and will then write it to the client.

Jump to

Keyboard shortcuts

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