| Method | What it does |
| Dns.parse(bytes) | A message: { id, qr, opcode, aa, tc, rd, ra, rcode, questions: [{ name, type, cls }], answers, authority, additional }; each record is { name, type, cls, ttl, value } with the data as text ("93.184.216.34", "10 mail.example.com", "\"some\" \"text\""), or "(N bytes)" for other types. Throws an Error saying what is wrong when the message is cut short or malformed. |
| Dns.response(query, answers, options) | A Uint8Array answering a parsed query: its first question, then the answers [{ name, type, ttl, value }]. options: { rcode, aa }. |
| Dns.encodeValue(type, text) | The record data bytes for a value written as text (A, AAAA, CNAME, NS, PTR, MX “priority host”, SRV “priority weight port target”, TXT); throws an Error with what is wrong. |
| Dns.readName(bytes, offset) | [name, offset after it], following compression pointers. |
| Dns.TYPES, Dns.typeName(number), Dns.RCODES | The record type numbers by name, a type's name ("TYPE99" for unknown ones), and the response code names. |
| Dns.validateEntry(entry) | For an entry { on, name, type, value, ttl }: null when it can be answered, else what is wrong. |
| Dns.entriesFor(entries, name) | The enabled, valid entries for a name: the exact ones, or else those of the closest wildcard. |
| Dns.resolve(entries, name, type) | The answers for a question, following CNAME entries, ready for Dns.response; null when no entry covers the name, [] when it has entries but none of that type. |
| Dns.upstreamAddress(text) | A resolver address with its port: "1.1.1.1" → "1.1.1.1:53", "2606:4700::1111" → "[2606:4700::1111]:53". |