@TODO
Field | Type | Required | Default | Description |
---|---|---|---|---|
id | Number |
❌ | 0 | ID |
flags | Number |
❌ | 0 | Flags |
questions | Query.Collection |
❌ | [] | QD Records |
answers | Resource.Collection |
❌ | [] | AN Records |
authorities | Resource.Collection |
❌ | [] | NS Records |
additional | Resource.Collection |
❌ | [] | AD Records |
Encode the packet instance into a new buffer.
Creates a new Packet instance from the given buffer.
Type | Required | Description | |
---|---|---|---|
dataView | DataView |
✔️ | Buffer to fill with data |
ctx | Object |
✔️ | State of the buffer r/w process |
Return the bitmask of the flag designated by name
.
Type | Required | Description | |
---|---|---|---|
name | String |
✔️ | Name of the target bitmask |
Name | Section | Mask | Description |
---|---|---|---|
RCODE |
RCODE |
0xF | |
RECURSION_AVAILABLE |
RA |
0x80 | |
RECURSION_DESIRED |
RD |
0x100 | |
TRUNCATED |
TC |
0x200 | |
AUTHORITATIVE |
AA |
0x400 | |
OPCODE |
OPCODE |
0x7800 | |
RESPONSE |
QR |
0x8000 |
Returns the value of the flag designated by name
.
Name | Section | Range | Description |
---|---|---|---|
RCODE |
RCODE |
0 -> 127 | |
RECURSION_AVAILABLE |
RA |
0 -> 1 | |
RECURSION_DESIRED |
RD |
0 -> 1 | |
TRUNCATED |
TC |
0 -> 1 | |
AUTHORITATIVE |
AA |
0 -> 1 | |
OPCODE |
OPCODE |
0 -> 127 | |
RESPONSE |
QR |
0 -> 1 |
Field | Type | Required | Default | Description |
---|---|---|---|---|
name | String |
✔️ | Name | |
type | Query.Type |
✔️ | Type | |
class | Query.Class |
✔️ | Class |
Same fields as Record
Same fields as Query
Field | Type | Required | Default | Description |
---|---|---|---|---|
unicastResponse | Boolean |
❌ | false | Whether the reply should be unicast |
Same fields as Record
Field | Type | Required | Default | Description |
---|---|---|---|---|
ttl | Number |
❌ | 0 | Record TTL (in seconds) |
Same fields as Record
Field | Type | Required | Default | Description |
---|---|---|---|---|
flushCache | Boolean |
❌ | false | Whether this record should flush cache |
Encode / Parse DNS unsigned int representation
Encode the given value to the buffer at the given offset (ctx.offset
) with the given size (nbBits
).
Type | Required | Description | |
---|---|---|---|
dataView | DataView |
✔️ | Buffer to fill with data |
ctx | Object |
✔️ | State of the buffer r/w process |
nbBits | Number |
✔️ | Amount of bits used for the value |
val | Number |
✔️ | The number to write |
Parse the value with the given size (nbBits
) next to the given offset (ctx.offset
) from the buffer.
Type | Required | Description | |
---|---|---|---|
dataView | DataView |
✔️ | Buffer to read data from |
ctx | Object |
✔️ | State of the buffer r/w process |
nbBits | Number |
✔️ | Amount of bits used for the value |
Encode / Parse DNS character string representation
Encoding | Bytes | Encode | Parse |
---|---|---|---|
ASCII | 1 | ✔️ | ✔️ |
UTF-8 | 2 | ✔️ | ✔️ |
UTF-8 | 3 | ✔️ | ✔️ |
Encode the given string to the buffer at the given offset (ctx.offset
).
Type | Required | Description | |
---|---|---|---|
dataView | DataView |
✔️ | Buffer to fill with data |
ctx | Object |
✔️ | State of the buffer r/w process |
str | String |
✔️ | The string to write |
Parse the string next to the given offset (ctx.offset
) from the buffer.
Type | Required | Description | |
---|---|---|---|
dataView | DataView |
✔️ | Buffer to read data from |
ctx | Object |
✔️ | State of the buffer r/w process |
Encode / Parse DNS address representation
Feature | Encode | Parse |
---|---|---|
IPV4 | ✔️ | ✔️ |
IPV6 | ❌ | ❌ |
Encode the given address to the buffer at the given offset (ctx.offset
).
Type | Required | Description | |
---|---|---|---|
dataView | DataView |
✔️ | Buffer to fill with data |
ctx | Object |
✔️ | State of the buffer r/w process |
address | String | ✔️ | The address to write |
Parse the address next to the given offset (ctx.offset
) from the buffer.
Automatically uncompress the address if a pointer is detected.
Type | Required | Description | |
---|---|---|---|
dataView | DataView |
✔️ | Buffer to read data from |
ctx | Object |
✔️ | State of the buffer r/w process |
Encode / Parse DNS domain representation
Feature | Encode | Parse |
---|---|---|
Compression | ✔️ | ✔️ |
Encode the given domain to the buffer at the given offset (ctx.offset
).
Automatically compress the domain if it was previously (fully or partially) added to the buffer.
Type | Required | Description | |
---|---|---|---|
dataView | DataView |
✔️ | Buffer to fill with data |
ctx | Object |
✔️ | State of the buffer r/w process |
domain | String | ✔️ | The domain to write |
Parse the domain next to the given offset (ctx.offset
) from the buffer.
Automatically uncompress the domain if a pointer is detected.
Type | Required | Description | |
---|---|---|---|
dataView | DataView |
✔️ | Buffer to read data from |
ctx | Object |
✔️ | State of the buffer r/w process |