responder

package
v0.0.0-...-67cf1be Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableIPv4

func DisableIPv4(r *Responder) error

DisableIPv4 is a server option that prevents the server from listening for IPv4 messages.

func DisableIPv6

func DisableIPv6(r *Responder) error

DisableIPv6 is a server option that prevents the server from listening for IPv6 messages.

Types

type Answer

type Answer struct {
	// Unique contains the records that belong to "unique" record sets.
	//
	// A "unique" resource record set is one where all the records with
	// that name, rrtype, and rrclass are conceptually under the control
	// or ownership of a single responder, and it is expected that at
	// most one responder should respond to a query for that name,
	// rrtype, and rrclass.
	//
	// See // https://tools.ietf.org/html/rfc6762#section-2.
	Unique ResponseSections

	// SharedScope contains the records that belong to "shared" record sets.
	//
	// A "shared" resource record set is is one where several Multicast DNS
	// responders may have records with the same name, rrtype, and
	// rrclass, and several responders may respond to a particular query.
	//
	// See // https://tools.ietf.org/html/rfc6762#section-2.
	Shared ResponseSections
}

Answer is an answer to a DNS question.

type Answerer

type Answerer interface {
	// Answer populates an answer to a single DNS question.
	// The implementation must allow concurrent calls.
	Answer(context.Context, *Question, *Answer) error
}

Answerer is an interface that provides answers to DNS questions.

type Option

type Option func(*Responder) error

Option is a function that applies an option to a server created by NewServer().

func UseInterface

func UseInterface(iface net.Interface) Option

UseInterface sets the network interface that is used by the server.

If this option is not provided, the server will choose the interface used to access the internet.

func UseLogger

func UseLogger(l twelf.Logger) Option

UseLogger returns a server option that sets the logger used by the server.

type Question

type Question struct {
	dns.Question

	Query     *dns.Msg
	Interface net.Interface
}

Question encapsulates a DNS question.

type Responder

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

Responder is an implementation of a multicast DNS responder for a single network interface.

func New

func New(
	answerer Answerer,
	options ...Option,
) (*Responder, error)

New returns a new mDNS server.

func (*Responder) Run

func (r *Responder) Run(ctx context.Context) error

Run response to mDNS messages until ctx is canceled or an error occurs.

type ResponseSections

type ResponseSections struct {
	AnswerSection     []dns.RR
	AuthoritySection  []dns.RR
	AdditionalSection []dns.RR
}

ResponseSections contains the various response sections of a response to a DNS query.

func (*ResponseSections) Additional

func (rs *ResponseSections) Additional(records ...dns.RR)

Additional appends records to the "additional" section of the answer.

func (*ResponseSections) Answer

func (rs *ResponseSections) Answer(records ...dns.RR)

Answer appends records to the "answer" section of the answer.

func (*ResponseSections) Authority

func (rs *ResponseSections) Authority(records ...dns.RR)

Authority appends records to the "authority" section of the answer.

func (*ResponseSections) IsEmpty

func (rs *ResponseSections) IsEmpty() bool

IsEmpty returns true if the response does not contain any records.

type UnionAnswerer

type UnionAnswerer []Answerer

UnionAnswerer is an answerer that combines answers from multiple answerers.

func (UnionAnswerer) Answer

func (an UnionAnswerer) Answer(ctx context.Context, q *Question, a *Answer) error

Answer populates an answer to a single DNS question. The implementation must allow concurrent calls.

Jump to

Keyboard shortcuts

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