nsutil

package
v1.6.24 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNilRR = errors.New("is nil")

ErrNilRR is returned when a parsed RR is nil.

Functions

func AddMessagesToReply

func AddMessagesToReply(ctx context.Context, reply *dns.Msg, level log.Severity, msgs ...string)

AddMessagesToReply creates information resource records using MakeMessageRecord and immediately adds them to the extra section of the given reply. If an error occurs, the resource record will not be added, and the error will be logged.

func MakeMessageRecord

func MakeMessageRecord(level log.Severity, msg string) (dns.RR, error)

MakeMessageRecord creates an informational resource record that can be added to the extra section of a reply.

Types

type RRProvider

type RRProvider interface {
	// GetExtraRRs is called when a DNS response to a DNS message is
	// crafted because the request is either denied or blocked.
	GetExtraRRs(ctx context.Context, request *dns.Msg) []dns.RR
}

RRProvider defines the interface that any block/deny reason interface may implement to support adding additional DNS resource records to the DNS responses extra (additional) section.

type Responder

type Responder interface {
	// ReplyWithDNS is called when a DNS response to a DNS message is
	// crafted because the request is either denied or blocked.
	ReplyWithDNS(ctx context.Context, request *dns.Msg) *dns.Msg
}

Responder defines the interface that any block/deny reason interface may implement to support sending custom DNS responses for a given reason. That is, if a reason context implements the Responder interface the ReplyWithDNS method will be called instead of creating the default zero-ip response.

type ResponderFunc

type ResponderFunc func(ctx context.Context, request *dns.Msg) *dns.Msg

ResponderFunc is a convenience type to use a function directly as a Responder.

func BlockIP

func BlockIP(msgs ...string) ResponderFunc

BlockIP is a ResponderFunc than replies with either 0.0.0.17 or ::17 for each A or AAAA question respectively. If there is no A or AAAA question, it defaults to replying with NXDomain.

func Localhost

func Localhost(msgs ...string) ResponderFunc

Localhost is a ResponderFunc than replies with localhost IP addresses. If there is no A or AAAA question, it defaults to replying with NXDomain.

func NxDomain

func NxDomain(msgs ...string) ResponderFunc

NxDomain returns a ResponderFunc that replies with NXDOMAIN.

func Refused

func Refused(msgs ...string) ResponderFunc

Refused returns a ResponderFunc that replies with REFUSED.

func ServerFailure

func ServerFailure(msgs ...string) ResponderFunc

ServerFailure returns a ResponderFunc that replies with SERVFAIL.

func ZeroIP

func ZeroIP(msgs ...string) ResponderFunc

ZeroIP is a ResponderFunc than replies with either 0.0.0.0 or :: for each A or AAAA question respectively. If there is no A or AAAA question, it defaults to replying with NXDomain.

func (ResponderFunc) MarshalJSON

func (rf ResponderFunc) MarshalJSON() ([]byte, error)

MarshalJSON disables JSON marshaling for ResponderFunc.

func (ResponderFunc) ReplyWithDNS

func (rf ResponderFunc) ReplyWithDNS(ctx context.Context, request *dns.Msg) *dns.Msg

ReplyWithDNS implements the Responder interface and calls rf.

Jump to

Keyboard shortcuts

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