Documentation
¶
Overview ¶
Package resolve implements a toy DNS resolver.
Index ¶
- Constants
- func DecodeCompressedName(length int, r io.ReadSeeker) ([]byte, error)
- func DecodeName(r io.ReadSeeker) ([]byte, error)
- func EncodeDNSName(s string) []byte
- func ID() uint16
- func LookupDomain(name string) (netip.Addr, error)
- func NewQuery(domain string, t Type) ([]byte, error)
- func Resolve(domain string, t Type) (netip.Addr, error)
- type Class
- type Header
- type Packet
- type Question
- type Record
- type Type
Constants ¶
View Source
const (
FlagRecursionDesired uint16 = 1 << 8
)
Flag constants.
View Source
const RootNSIP = "198.41.0.4"
Variables ¶
This section is empty.
Functions ¶
func DecodeCompressedName ¶
func DecodeCompressedName(length int, r io.ReadSeeker) ([]byte, error)
DecodeCompressedName decodes a compressed DNS name.
func EncodeDNSName ¶
EncodeDNSName encodes a domain name for DNS.
Types ¶
type Header ¶
type Header struct {
ID uint16
Flags uint16
NumQuestions uint16
NumAnswers uint16
NumAuthorities uint16
NumAdditionals uint16
}
Header is a DNS header.
func DecodeHeader ¶
DecodeHeader decodes a DNS header.
func (*Header) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler for Header.
func (*Header) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler for Header.
type Packet ¶
type Packet struct {
Header Header
Questions []Question
Answers []Record
Authorities []Record
Additionals []Record
}
Packet represents a DNS packet.
func DecodePacket ¶
func DecodePacket(r io.ReadSeeker) (*Packet, error)
DecodePacket decodes a DNS packet.
func (Packet) Nameserver ¶
Nameserver returns the domain from the first NS record in the Authority section.
type Question ¶
Question is a DNS question.
func DecodeQuestion ¶
func DecodeQuestion(r io.ReadSeeker) (Question, error)
DecodeQuestion decodes a DNS question.
func (*Question) MarshalBinary ¶
type Record ¶
Record represents a DNS record.
func DecodeRecord ¶
func DecodeRecord(r io.ReadSeeker) (Record, error)
DecodeRecord decodes a DNS record.
Click to show internal directories.
Click to hide internal directories.