DNS over HTTPS JSON API needs some tweaks


#1

The new DNS over HTTPS JSON API is nice (and #ty for keeping it similar to Google’s; grassroots standards FTW) but you may want to look at quoting at least TXT record responses.

curl 'https://cloudflare-dns.com/dns-query?ct=application/dns-json&name=google-public-dns-a.google.com&type=TXT'

returns:

{"Status": 0,"TC": false,"RD": true, "RA": true, "AD": false,"CD": false,"Question":[{"name": "google-public-dns-a.google.com.", "type": 16}],"Answer":[{"name": "google-public-dns-a.google.com.", "type": 16, "TTL": 3516, "data": ""http://xkcd.com/1361/""}]}

and the data component in Answer is malformed.


TXT record info not being properly escaped?
#2

And, I hit submit too soon.

Also: Google’s DNS over HTTPS JSON API lets users submit numerical types as well as alpha one. e.g. 255 as well as ANY. Is there a plan to normalize this as well?

And, since I just noticed “ANY” is an invalid query, I tried it with 1 (A) and that does not work so it wasn’t just an error with ANY. Noting that ANY is not supported wld be gd as well.

For reference, the context for these questions is a new R package: dnsflare.


#3

@hrbrmstr thanks for reporting! Numerical values for types should already work. The ANY query is not supported (see the Status field in the JSON response), I’ll update the documentation to reflect that. I’m already tracking the broken escaping in TXT answers, I’ll let you know when the fix rolls out.


#4

I’ll try the numeric again (I may be sending a JSON string vs integer). Thx for the quick response!


#5

Yep. That was it. If it’s a JSON integer it works great. Thx!


#6

The string data is now properly escaped, let me know if you encounter any other problems:

$ curl 'https://1.1.1.1/dns-query?ct=application/dns-json&name=google-public-dns-a.google.com&type=TXT' | jq .
{
  "Status": 0,
  "TC": false,
  "RD": true,
  "RA": true,
  "AD": false,
  "CD": false,
  "Question": [
    {
      "name": "google-public-dns-a.google.com.",
      "type": 16
    }
  ],
  "Answer": [
    {
      "name": "google-public-dns-a.google.com.",
      "type": 16,
      "TTL": 86400,
      "data": "\"http://xkcd.com/1361/\""
    }
  ]
}

#7

works perfectly! #ty