Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save helloimalastair/69e0e79cd9394aa6d31ed77153a9bef2 to your computer and use it in GitHub Desktop.
Save helloimalastair/69e0e79cd9394aa6d31ed77153a9bef2 to your computer and use it in GitHub Desktop.
CloudflareDNSResolver.ts
/* These types were generated messily by hand, and thus will probably not be the most intuitive, but they should be correct according to current Cloudflare DNS resolution Output. Pulled from the current CF DNS Spec at https://developers.cloudflare.com/1.1.1.1/encrypted-dns/dns-over-https/make-api-requests/dns-json */
declare type DNSJSON = {
/* The Response Code of the DNS Query. These are defined here: https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6 */
Status: DNSRequestStatus,
/* If true, it means the truncated bit was set. This happens when the DNS answer is larger than a single UDP or TCP packet. TC will almost always be false with Cloudflare DNS over HTTPS because Cloudflare supports the maximum response size. */
TC: Boolean,
/* If true, it means the Recursive Desired bit was set. This is always set to true for Cloudflare DNS over HTTPS. */
RD: Boolean,
/* If true, it means the Recursion Available bit was set. This is always set to true for Cloudflare DNS over HTTPS. */
RA: Boolean,
/* If true, it means that every record in the answer was verified with DNSSEC. */
AD: Boolean,
/* If true, the client asked to disable DNSSEC validation. In this case, Cloudflare will still fetch the DNSSEC-related records, but it will not attempt to validate the records. */
CD: Boolean,
/* DNS Request */
Question: Array<DNSQuestion>,
/* Resolver Response */
Answer: Array<DNSAnswer>
};
declare enum DNSRequestStatus {
NoError = 0,
FormErr = 1,
ServFail = 2,
NXDomain = 3,
NotImp = 4,
Refused = 5,
YXDomain = 6,
YXRRSet = 7,
NXRRSet = 8,
NotAuth = 9,
NotZone = 10,
DSOTYPENI = 11,
BADVERS = 16,
BADSIG = 16,
BADKEY = 17,
BADTIME = 18,
BADMODE = 19,
BADNAME = 20,
BADALG = 21,
BADTRUNC = 22,
BADCOOKIE = 23
};
declare type DNSQuestion = {
/* The record name requested. */
name: string;
/* The type of DNS record requested. These are defined here: https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4 */
type: DNSRecordType;
};
declare type DNSAnswer = {
/* The record owner. */
name: string;
/* The type of DNS record resolved. These are defined here: https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4 */
type: DNSRecordType;
/* The number of seconds the answer can be stored in cache before it is considered stale. */
TTL: number;
/* The value of the DNS record for the given name and type. The data will be in text for standardized record types and in hex for unknown types. */
data: string;
};
declare enum DNSRecordType {
A = 1,
NS = 2,
MD = 3,
MF = 4,
CNAME = 5,
SOA = 6,
MB = 7,
MG = 8,
MR = 9,
NULL = 10,
WKS = 11,
PTR = 12,
HINFO = 13,
MINFO = 14,
MX = 15,
TXT = 16,
RP = 17,
AFSDB = 18,
X25 = 19,
ISDN = 20,
RT = 21,
NSAP = 22,
"NSAP-PTR" = 23,
SIG = 24,
KEY = 25,
PX = 26,
GPOS = 27,
AAAA = 28,
LOC = 29,
NXT = 30,
EID = 31,
NIMLOC = 32,
SRV = 33,
ATMA = 34,
NAPTR = 35,
KX = 36,
CERT = 37,
A6 = 38,
DNAME = 39,
SINK = 40,
OPT = 41,
APL = 42,
DS = 43,
SSHFP = 44,
IPSECKEY = 45,
RRSIG = 46,
NSEC = 47,
DNSKEY = 48,
DHCID = 49,
NSEC3 = 50,
NSEC3PARAM = 51,
TLSA = 52,
SMIMEA = 53,
HIP = 55,
NINFO = 56,
RKEY = 57,
TALINK = 58,
CDS = 59,
CDNSKEY = 60,
OPENPGPKEY = 61,
CSYNC = 62,
ZONEMD = 63,
SVCB = 64,
HTTPS = 65,
SPF = 99,
UINFO = 100,
UID = 101,
GID = 102,
UNSPEC = 103,
NID = 104,
L32 = 105,
L64 = 106,
LP = 107,
EUI48 = 108,
EUI64 = 109,
TKEY = 249,
TSIG = 250,
IXFR = 251,
AXFR = 252,
MAILB = 253,
MAILA = 254,
URI = 256,
CAA = 257,
AVC = 258,
DOA = 259,
AMTRELAY = 260,
TA = 32768,
DLV = 32769,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment