dnsutil

package
v0.0.0-...-512dd01 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxUdpMsgSize              = 1400 // rfc9715
	ResponsePaddingBlockLength = 468  // rfc8467
)
View Source
const (
	ProtoUDP = "UDP"
	ProtoTCP = "TCP"
	ProtoTLS = "TLS"
)
View Source
const MaxTxtStringSize = 255

Variables

View Source
var PrintableAscii = &unicode.RangeTable{
	R16: []unicode.Range16{
		{0x0020, 0x007e, 1},
	},
	LatinOffset: 1,
}

Functions

func AddPadding

func AddPadding(msg *dns.Msg, blockLength int)

adds edns0 padding to msg so that the padded length is a multiple of blockLength

func CheckAndSetEdns

func CheckAndSetEdns(req, resp *dns.Msg) error

checks for edns0 in req, sets edns0 in resp

func EqualsAsciiIgnoreCase

func EqualsAsciiIgnoreCase(s, t string) bool

fast, ascii-only, case-insensitive string equality check

func GetMaxUdpSize

func GetMaxUdpSize(req *dns.Msg) int

determines max udp payload size

func GetProtocol

func GetProtocol(w dns.ResponseWriter) string

func HasPadding

func HasPadding(msg *dns.Msg) bool

checks if edns0 padding exists in msg

func MsgAcceptFunc

func MsgAcceptFunc(dh dns.Header) dns.MsgAcceptAction

func ResizeForTransport

func ResizeForTransport(req, resp *dns.Msg, proto string)

truncates and/or pads if necessary

func SplitForTxt

func SplitForTxt(s string) []string

splits the given string into a slice of strings of suitable lengths for dns.TXT(https://pkg.go.dev/github.com/miekg/dns#TXT) data

func ToLowerAscii

func ToLowerAscii(s string) string

fast, ascii-only string case lower-er

func ToPrintableAscii

func ToPrintableAscii(s string) string

attempts to replace all non-ascii characters with ascii approximations, then removes all non-ascii characters and ascii control characters

Types

type DnssecProvider

type DnssecProvider struct {
	Ksk        *dns.DNSKEY
	Zsk        *dns.DNSKEY
	ZskPrivKey crypto.Signer
	KeySig     *dns.RRSIG
	NsecTypes  []uint16
}

func GenerateDnssecProvider

func GenerateDnssecProvider(name string, algo uint8, rrTtl, validFrom, validTo uint32) (*DnssecProvider, error)

func (*DnssecProvider) DS

func (p *DnssecProvider) DS() (*dns.DS, error)

func (*DnssecProvider) PrivKeyBytes

func (p *DnssecProvider) PrivKeyBytes() ([]byte, error)

func (*DnssecProvider) Prove

func (p *DnssecProvider) Prove(req, resp *dns.Msg, validFrom, validTo uint32) error

adds DNSSEC signatures to resp

func (*DnssecProvider) ProvideKeys

func (p *DnssecProvider) ProvideKeys(req, resp *dns.Msg) bool

adds DNSSEC keys (and keysig) to resp if requested by req, returns true iff keys were added

func (*DnssecProvider) SetPrivKeyBytes

func (p *DnssecProvider) SetPrivKeyBytes(b []byte) error

func (*DnssecProvider) Sign

func (p *DnssecProvider) Sign(rrs []dns.RR, validFrom, validTo uint32) (sigs []dns.RR, err error)

type IPCollection

type IPCollection struct {
	IPv4 []net.IP
	IPv6 []net.IP
}

func (*IPCollection) Add

func (c *IPCollection) Add(ip net.IP)

func (*IPCollection) MarshalJSON

func (c *IPCollection) MarshalJSON() ([]byte, error)

func (*IPCollection) UnmarshalJSON

func (c *IPCollection) UnmarshalJSON(data []byte) error

type LoggingHandler

type LoggingHandler struct {
	Logger *log.Logger
	Next   dns.Handler
	// contains filtered or unexported fields
}

func (*LoggingHandler) RequestCount

func (h *LoggingHandler) RequestCount() uint64

func (*LoggingHandler) ServeDNS

func (h *LoggingHandler) ServeDNS(w dns.ResponseWriter, req *dns.Msg)

type LoggingResponseWriter

type LoggingResponseWriter struct {
	dns.ResponseWriter
	Start   time.Time
	Rcode   int
	AnCount int
	NsCount int
	ExCount int
	// contains filtered or unexported fields
}

func (*LoggingResponseWriter) ConnectionState

func (w *LoggingResponseWriter) ConnectionState() *tls.ConnectionState

func (*LoggingResponseWriter) WriteMsg

func (w *LoggingResponseWriter) WriteMsg(m *dns.Msg) error

type RecordGenerator

type RecordGenerator interface {
	GenerateRecords(question *dns.Question, zone string) (rrs []dns.RR, validName bool)
}

type SimpleHandler

type SimpleHandler struct {
	RecordGenerator
	UpdateHandler
	*DnssecProvider
	Zone           string
	Ns             []string
	HostMasterMbox string
	StaticRecords  StaticRecords
	// contains filtered or unexported fields
}

func (*SimpleHandler) Init

func (h *SimpleHandler) Init(privKeyBytes []byte) *SimpleHandler

func (*SimpleHandler) SOA

func (h *SimpleHandler) SOA(q *dns.Question, includeSig bool) (rrs []dns.RR)

func (*SimpleHandler) ServeDNS

func (h *SimpleHandler) ServeDNS(w dns.ResponseWriter, req *dns.Msg)

type StaticRecords

type StaticRecords []dns.RR

func (StaticRecords) Get

func (s StaticRecords) Get(question *dns.Question) (rrs []dns.RR, nameExists bool)

func (StaticRecords) MarshalJSON

func (s StaticRecords) MarshalJSON() ([]byte, error)

func (*StaticRecords) UnmarshalJSON

func (p *StaticRecords) UnmarshalJSON(data []byte) error

type UpdateHandler

type UpdateHandler interface {
	HandleUpdate(w dns.ResponseWriter, req *dns.Msg, zone string)
}

Jump to

Keyboard shortcuts

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