dnsutils

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPv4UdpMaxPayload = 1472 // MTU 1500 - 20 IPv4 header - 8 udp header
	IPv6UdpMaxPayload = 1452 // MTU 1500 - 40 IPv6 header - 8 udp header
)

Variables

This section is empty.

Functions

func AddECS added in v2.2.1

func AddECS(opt *dns.OPT, ecs *dns.EDNS0_SUBNET, overwrite bool) (newECS bool)

AddECS adds ecs to opt.

func ApplyMaximumTTL

func ApplyMaximumTTL(m *dns.Msg, ttl uint32)

func ApplyMinimalTTL

func ApplyMinimalTTL(m *dns.Msg, ttl uint32)

func FakeSOA added in v2.1.2

func FakeSOA(name string) *dns.SOA

func GenEmptyReply added in v2.1.2

func GenEmptyReply(q *dns.Msg, rcode int) *dns.Msg

func GetECS added in v2.2.1

func GetECS(opt *dns.OPT) (e *dns.EDNS0_SUBNET)

func GetEDNS0Option added in v2.2.1

func GetEDNS0Option(opt *dns.OPT, option uint16) dns.EDNS0

func GetMinimalTTL

func GetMinimalTTL(m *dns.Msg) uint32

GetMinimalTTL returns the minimal ttl of this msg. If msg m has no record, it returns 0.

func GetMsgECS

func GetMsgECS(m *dns.Msg) (e *dns.EDNS0_SUBNET)

func IsIOErr

func IsIOErr(err error) (innerErr error)

func NewEDNS0Subnet

func NewEDNS0Subnet(ip net.IP, mask uint8, v6 bool) *dns.EDNS0_SUBNET

func PadToMinimum added in v2.2.1

func PadToMinimum(m *dns.Msg, minLen int) (upgraded, newPadding bool)

PadToMinimum pads m to the minimum length. If the length of m is larger than minLen, PadToMinimum won't do anything. upgraded indicates the m was upgraded to an EDNS0 msg. newPadding indicates the Padding option is new to m.

func QclassToString

func QclassToString(u uint16) string

func QtypeToString

func QtypeToString(u uint16) string

func ReadMsgFromTCP

func ReadMsgFromTCP(c io.Reader) (m *dns.Msg, n int, err error)

ReadMsgFromTCP reads msg from c in RFC 7766 format. n represents how many bytes are read from c. This includes two-octet length field. An io err will be wrapped into an IOErr. IsIOErr(err) can check and unwrap the inner io err.

func ReadMsgFromUDP

func ReadMsgFromUDP(c io.Reader, bufSize int) (m *dns.Msg, n int, err error)

ReadMsgFromUDP See ReadUDPMsgFrom.

func ReadUDPMsgFrom

func ReadUDPMsgFrom(c net.PacketConn, bufSize int) (m *dns.Msg, from net.Addr, n int, err error)

ReadUDPMsgFrom reads dns msg from c in a wire format. The bufSize should not be greater than dns.MaxMsgSize. Typically IPv4UdpMaxPayload is big enough. An io err will be wrapped into an IOErr. IsIOErr(err) can check and unwrap the inner io err.

func RemoveECS

func RemoveECS(opt *dns.OPT)

func RemoveEDNS0 added in v2.2.1

func RemoveEDNS0(m *dns.Msg)

RemoveEDNS0 removes the OPT record from m.

func RemoveEDNS0Option added in v2.2.1

func RemoveEDNS0Option(opt *dns.OPT, option uint16)

func RemoveMsgECS added in v2.2.1

func RemoveMsgECS(m *dns.Msg)

RemoveMsgECS removes the *dns.EDNS0_SUBNET record in m.

func SetTTL

func SetTTL(m *dns.Msg, ttl uint32)

SetTTL updates all records' ttl to ttl, except opt record.

func SubtractTTL

func SubtractTTL(m *dns.Msg, delta uint32) (overflowed bool)

SubtractTTL subtract delta from every m's RR. If RR's TTL is smaller than delta, SubtractTTL will return overflowed = true.

func UpgradeEDNS0 added in v2.2.1

func UpgradeEDNS0(m *dns.Msg) *dns.OPT

UpgradeEDNS0 enables EDNS0 for m and returns it's dns.OPT record. m must be a msg without dns.OPT.

func WriteMsgToTCP

func WriteMsgToTCP(c io.Writer, m *dns.Msg) (n int, err error)

WriteMsgToTCP packs and writes m to c in RFC 7766 format. n represents how many bytes are written to c. This includes 2 bytes length header. An io err will be wrapped into an IOErr. IsIOErr(err) can check and unwrap the inner io err.

func WriteMsgToUDP

func WriteMsgToUDP(c io.Writer, m *dns.Msg) (n int, err error)

WriteMsgToUDP packs and writes m to c in a wire format. An io err will be wrapped into an IOErr. IsIOErr(err) can check and unwrap the inner io err.

func WriteRawMsgToTCP

func WriteRawMsgToTCP(c io.Writer, b []byte) (n int, err error)

WriteRawMsgToTCP See WriteMsgToTCP

func WriteRawMsgToUDP

func WriteRawMsgToUDP(c io.Writer, b []byte) (n int, err error)

WriteRawMsgToUDP See WriteMsgToUDP.

func WriteUDPMsgTo

func WriteUDPMsgTo(m *dns.Msg, c net.PacketConn, to net.Addr) (n int, err error)

WriteUDPMsgTo See WriteMsgToUDP.

Types

type IOErr

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

func WrapIOErr

func WrapIOErr(err error) *IOErr

func (*IOErr) Error

func (e *IOErr) Error() string

func (*IOErr) Unwrap

func (e *IOErr) Unwrap() error

Jump to

Keyboard shortcuts

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