dig.wtf

Years ago, I needed to run dig on my cellphone, and there weren’t great solutions at the time. Most websites that would allow you to run dig or nslookup commands weren’t optimized for cell phones, and it’s surprising how often I needed to run dig commands from hosts outside corporate firewalls.

The first version of dig.wtf was written in Golang and ran on AWS Elastic Beanstalk.

I rewrote the site in Python to run in Lambda a couple of years later. The primary inspiration for this rewrite was to reduce my costs. This site never got enough traffic to justify the roughly $20 a month that Elastic Beanstalk was costing. You get a million invocations a month for free with Lambda, which would be more than enough.

Version two was fine for about three years. However, I wasn’t thrilled with how the site would refresh when being searched, so I wanted to rewrite it as a Single Page App. I looked at Angular, React, and some other frameworks, but they were too heavy and had too many dependencies for this application but landed on backbone.js.

Additionally, I had started using Cloudflare Pages to host some sites, and I was wondering if it was possible to use Cloudflare Workers for this. Cloudflare Workers relies on V8 and supports Javascript and WASM. It turned out that it was possible to resolve the DNS requests using DNS over HTTPS:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
async function dnsRequest(name, type) {
	const response = await fetch(
		"https://cloudflare-dns.com/dns-query?name=" +
		name +
		"&type=" +
		type +
		"&ct=application/dns-json"
	);

	return response;
}

The ANY DNS query type is being deprecated and you have to make explicit requests for each DNS type. With Cloudflare Workers, this can get expensive quickly. With a Worker, you get 100,000 invocations for free each day but each outbound HTTP request counts as an additional invocation. As a result, dig.wtf is currently only resolving A, AAAA, NS, MX, TXT, and SOA records.