NLnetLabs / dnsi

A tool to investigate the DNS.
BSD 3-Clause "New" or "Revised" License
43 stars 4 forks source link

Json output #32

Open tertsdiepraam opened 1 week ago

tertsdiepraam commented 1 week ago

Here's some example output (still WIP and suggestions are welcome):

Custom JSON format

> dnsi query nlnetlabs.nl --format=json
{
  "message": {
    "id": 62706,
    "qr": true,
    "opcode": "QUERY",
    "qdcount": 1,
    "ancount": 1,
    "nscount": 0,
    "arcount": 1,
    "question": {
      "name": "nlnetlabs.nl.",
      "type": "AAAA",
      "class": "IN"
    },
    "answer": [
      {
        "owner": "nlnetlabs.nl",
        "class": "IN",
        "type": "AAAA",
        "ttl": 240,
        "data": {
          "AAAA": {
            "addr": "2a01:4f8:c0c:cdfa::1"
          }
        }
      },
      {
        "owner": "nlnetlabs.nl.",
        "class": "IN",
        "type": "AAAA",
        "ttl": 240,
        "data": {
          "AAAA": {
            "addr": "2a01:4f8:c0c:cdfa::1"
          }
        }
      }
    ],
    "authority": [],
    "additional": [
      {
        "owner": ".",
        "class": "CLASS1232",
        "type": "OPT",
        "ttl": 0,
        "data": {
          "OPT": []
        }
      }
    ]
  },
  "stats": {
    "start": "2024-06-25T10:52:55.834028711+02:00",
    "duration": 22,
    "server_addr": "9.9.9.9:53",
    "server_proto": "UDP"
  }
}

RFC 8427 format

> dnsi query nlnetlabs.nl --format=rfc8427
{
  "dateString": "2024-06-25T10:54:10+02:00",
  "dateSeconds": 1719305650,
  "msgLength": 69,
  "ID": 5004,
  "QR": 1,
  "Opcode": 0,
  "AA": 0,
  "TC": 0,
  "RD": 1,
  "RA": 1,
  "AD": 0,
  "CD": 0,
  "RCODE": 0,
  "QDCOUNT": 1,
  "ANCOUNT": 1,
  "NSCOUNT": 0,
  "ARCOUNT": 1,
  "QNAME": "nlnetlabs.nl",
  "QTYPE": 28,
  "QTYPEname": "AAAA",
  "QCLASS": 1,
  "QCLASSname": "IN",
  "questionRRs": [
    {
      "TYPE": 28,
      "TYPEname": "AAAA",
      "CLASS": 1,
      "CLASSname": "IN"
    }
  ],
  "answerRRs": [
    {
      "NAME": "nlnetlabs.nl.",
      "TYPE": 28,
      "TYPEname": "AAAA",
      "CLASS": 1,
      "CLASSname": "IN",
      "TTL": 240,
      "rdataAAAA": "2a01:4f8:c0c:cdfa::1",
      "RDLENGTH": 16,
      "RDATAHEX": "2A0104F80C0CCDFA0000000000000001"
    }
  ],
  "authorityRRs": [],
  "additionalRRs": [],
  "EDNS": {
    "version": 0,
    "flags": [],
    "rcode": "NOERROR",
    "udpsize": 512
  }
}
tertsdiepraam commented 1 week ago

This now requires some changes in domain: https://github.com/NLnetLabs/domain/pull/343, so we might need to wait for a release there.