dnspacket-ts
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

DNS Packet

Node/Browser module for encoding and decoding DNS packet based on rfc 1035

Usage

import { decode, encode } from "dnspacket-ts";
import axios from 'axios';

const query: DNSQuery = {
  id: 153,
  flags: {
    RD: 1,
  },
  questions: [
    { CLASS: "IN", NAME: "google.com", TYPE: "AAAA" },
  ],
};

const data = encode(query);

(async () => {
  const rdr = await axios({
    url: 'https://cloudflare-dns.com/dns-query',
    method: 'POST',
    data,
    headers: { 'Content-Type': 'application/dns-message' },
    responseType: 'arraybuffer'
  });

  console.log(decode(rdr.data));
})();

Ressouces

Package Sidebar

Install

npm i dnspacket-ts

Weekly Downloads

13

Version

1.0.9

License

MIT

Unpacked Size

47 kB

Total Files

7

Last publish

Collaborators

  • haikel