exdns

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 5 Imported by: 3

Documentation

Overview

Package exdns contains helpers to work with dns.Msg

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsServerAddress

func AsServerAddress(server string) (string, error)

AsServerAddress validates and optionally appends :53 port if it wasn't specified already

func CleanString added in v0.7.25

func CleanString(v fmt.Stringer) string

CleanString replaces all whitespace on the `.String()` output of a command with single spaces, to turn them into readable fields in logs.

func Decanonize

func Decanonize(qName string) string

Decanonize removes the trailing . if present, unless it's the root dot

func ForEachAnswer

func ForEachAnswer[T dns.RR](msg *dns.Msg, fn func(v T))

ForEachAnswer calls a function for each answer of the specified type.

func ForEachQuestion added in v0.7.15

func ForEachQuestion(req *dns.Msg, fn func(dns.Question))

ForEachQuestion calls a function for each question on the given request.

func ForEachQuestionOfClass added in v0.7.15

func ForEachQuestionOfClass(req *dns.Msg, qClass uint16, fn func(dns.Question))

ForEachQuestionOfClass calls a function for each question of the specified class on the given request

func ForEachRR added in v0.7.18

func ForEachRR[T dns.RR](records []dns.RR, fn func(v T))

ForEachRR calls a function for each dns.RR of the specified type.

func GetFirstAnswer

func GetFirstAnswer[T dns.RR](msg *dns.Msg) T

GetFirstAnswer returns the first answer for a specified type.

func GetFirstRR added in v0.7.23

func GetFirstRR[T dns.RR](records []dns.RR) (T, bool)

GetFirstRR returns the first RR for a specified type on the given slice.

func HasAnswerType

func HasAnswerType(msg *dns.Msg, qType uint16) bool

HasAnswerType checks if a dns.Msg contains answers of the specified type.

func HasNsType

func HasNsType(msg *dns.Msg, qType uint16) bool

HasNsType checks if a dns.Msg contains Ns entries of the specified type

func NewRequestFromParts added in v0.7.24

func NewRequestFromParts(qName string, qClass uint16, qType uint16) *dns.Msg

NewRequestFromParts creates a new dns.Msg from the described question.

func RestoreReturn added in v0.7.19

func RestoreReturn(req, resp *dns.Msg, err error) (*dns.Msg, error)

RestoreReturn makes sure the response carries the same ID as the original request before returning it an already validated response.

func TrimQ

func TrimQ(s []dns.Question, cond func(q dns.Question) bool) []dns.Question

TrimQ removes entries matching the condition from a dns.Question slice

func TrimRR

func TrimRR(s []dns.RR, cond func(rr dns.RR) bool) []dns.RR

TrimRR removes entries matching the condition from a dns.RR slice

func ValidateResponse added in v0.7.17

func ValidateResponse(server string, resp *dns.Msg, err error) error

ValidateResponse wraps errors.ValidateResponse to avoid getting nil errors typed as *net.DNSError, which aren't nil anymore.

func ValidateRestoreReturn added in v0.7.19

func ValidateRestoreReturn(req, resp *dns.Msg,
	server string, err error) (*dns.Msg, error)

ValidateRestoreReturn validates a response and makes sure it carries the same ID as the original request

Types

This section is empty.

Jump to

Keyboard shortcuts

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