dnsutils

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: GPL-3.0 Imports: 7 Imported by: 1

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 AppendECS added in v1.5.0

func AppendECS(m *dns.Msg, ecs *dns.EDNS0_SUBNET) *dns.Msg

func ApplyMaximumTTL

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

func ApplyMinimalTTL

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

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 added in v1.5.0

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

func IsIOErr

func IsIOErr(err error) (innerErr error)

func NewEDNS0Subnet added in v1.5.0

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

func QclassToString added in v1.7.1

func QclassToString(u uint16) string

func QtypeToString added in v1.7.1

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 added in v1.5.0

func RemoveECS(m *dns.Msg) (removedECS *dns.EDNS0_SUBNET)

func SetTTL

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

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

func SubtractTTL added in v1.5.2

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 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