haikelfazzani / dns-packet

๐Ÿ—„๏ธ Node/Browser module for encoding and decoding DNS packet

Home Page:https://www.npmjs.com/package/dnspacket-ts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

๐Ÿ—„๏ธ Node/Browser module for encoding and decoding DNS packet

https://www.npmjs.com/package/dnspacket-ts

License:Apache License 2.0


Languages

Language:TypeScript 83.5%Language:JavaScript 16.5%