Encodes and decodes DNS message packets (derivative of dns-packet)
npm install dns-messagedns-message is a web-compatible encoder and decoder of DNS message packets (derivative of dns-packet)
The goal of dns-message is to be a derivative of dns-packet that uses typed arrays and DataViews to decode and encode DNS messages, removing the reliance on Node.js Buffer and being compatible with any JavaScript runtime that supports DataViews, while also having types baked-in.
For a full list of reference types, consult this library's typings.
A DNS message input or decoded message.
- accepts rtype: PacketRType which is set using PacketFlag values
- flags PacketFlag as a bitfield (includes rtype and type)
A DNS question input or decoded payload.
- qu reflects the class field, which is a bit field usually set to RecordClass
- Accepts a DNS packet of type Packet
Returns an encoded Uint8Array of the encoded DNS message
- Accepts binary data of a DNS message
- May throw built-in RangeErrors
Returns a decoded DNS Packet
- Accepts a DNS packet of type Packet
Returns amount of bytes required for encoding
- Accepts a DNS packet of type Packet
Returns an encoded Uint8Array of the encoded DNS message, prefixed with a UInt16-BE length for TCP encoding.
- Accepts binary data of a DNS message, prefixed with a UInt16-BE length
- May throw built-in RangeErrors
Returns a decoded DNS Packet