Skip to content

Conversation

@tertsdiepraam
Copy link
Contributor

@tertsdiepraam tertsdiepraam commented Jun 21, 2024

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
Copy link
Contributor Author

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

@tertsdiepraam tertsdiepraam marked this pull request as ready for review January 14, 2025 15:10
@tertsdiepraam
Copy link
Contributor Author

If we don't mind a git dependency on domain and an MSRV bump, this can be merged. Otherwise we'll have to wait.

@Philip-NLnetLabs
Copy link
Member

I wonder if we have a policy for that. Also whether a git reference should refer to a branch or to a specific commit.

@bal-e
Copy link

bal-e commented Mar 26, 2025

In the simple-json format, records are serialized like:

{
  "owner": "nlnetlabs.nl",
  "class": "IN",
  "type": "AAAA",
  "ttl": 240,
  "data": {
    "AAAA": {
      "addr": "2a01:4f8:c0c:cdfa::1"
    }
  }
}

data here always has a single key and it is always the same as the record type. Would it be possible to flatten the data field so that it looks like

{
  "owner": "nlnetlabs.nl",
  "class": "IN",
  "type": "AAAA",
  "ttl": 240,
  "data": {
    "addr": "2a01:4f8:c0c:cdfa::1"
  }
}

instead? I think serde has some support for this, with its "adjacently tagged" enum representation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants