DEV Community

Sameer Charles
Sameer Charles

Posted on

A small experiment with DoH in browser

I wanted to explore some new uses cases for DoH (DNS over HTTPS). The criteria was simple, anything thats useful for at least one person (thats usually just me) so I was set for the success.

I work with startups, from naming product, implementation to marketing. So I decided to build a small tool to find available domain names directly from the browser. That is, without using registrar's slow and sluggish websites.

Using a DNS resolver for domain lookup is not a fool proof method since it will result in false positives if the registrar has misconfigured the domain or if the registry have the domain as not reservable. Either way I decided to give it a go.

I used Node.js, WordNet data source for the dictionary and Cloudflare open DNS which is capable of DoH.

I will eventually open source the entire project (once cleaned up) but here is a quick snippet so you know how easy it is to do a lookup from your browser.

// Add doh.min.js
https://cdn.jsdelivr.net/npm/dohjs@latest/dist/doh.min.js

// Using cloudflare open dns resolver
const DNS = new doh.DohResolver('https://1.1.1.1/dns-query')

DNS.query('KickSmart.app', 'A')
.then(response => {
const available = response.rcode == 'NXDOMAIN' ? true : false
console.log('KickSmart.app is avaiable: '+available)
})
.catch(err => {
console.error(err)
})
.finally(() => {
console.log('Finished query!')
})

Thats it!

Here I am using Cloudflare open DNS but you can use any available DNS resolver capable of DoH like google open dns (used by Chrome) or your own DNS resolver.

As mentioned above, you will get some false positives time to time. But having the ability to privately and quickly search for domains made it worth.

The name of the project is IDEA Ramen, it's a simple yet powerful domain name generator.

All feedback and questions are welcome!


Top comments (0)