Sign inDemoInstall

Package Overview
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies


Package doh implements client operations for DoH (DNS over HTTPS) lookups.

Version published




Build Status GoDoc Go Report Card codecov

This is a Go client library implementation of DNS over HTTPS (RFC8484).

Compliance with DNS specifications

This client library doesn't currently implement all of the DNS specifications.

It implements looking up the following records:

  • A
  • AAAA
  • MX
  • NS
  • TXT
  • SRV
  • SOA
  • PTR

It also currently doesn't implement other query types than standard query, nor support for truncated messages. Full compliance, at least with RFC 1035, is something I'd like, though, so all of that should come in the future.


This client library should be as easy to use as any other DNS client library. The only difference is the transport layer it uses to perform lookups.

Here's a quick example:

package main

import (


func main() {
	resolver := doh.Resolver{
		Host:  "", // Change this with your favourite DoH-compliant resolver.
		Class: doh.IN,

	// Perform a A lookup on
	a, _, err := resolver.LookupA("")
	if err != nil {
	println(a[0].IP4) //

	// Perform a SRV lookup for e.g. a Matrix homeserver
	srv, _, err := resolver.LookupService("matrix", "tcp", "")
	if err != nil {
	println(srv[0].Target) //


I grew quite interested in how the Internet works lately, which implies spending some time reading DNS-related RFCs. On top of that, DNS over HTTPS is something I'm interested in quite a lot for privacy reasons and because of how harder it is to censor than classic DNS, so I decided to give it a go. And also because my definition of "having fun during holidays" obviously involves implementing part of the DNS RFC.


Contributions are more than welcome. I tried to make this library as friendly to hack on as possible, especially when the said hack aims to implement support for a new DNS record type. Here's an example of how to do so, which is the exhaustive changeset for the implementation of SOA records.

And of course, if you have any issue or feedback you want to report on, feel free to open an issue.


Last updated on 28 Oct 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.


Related posts

SocketSocket SOC 2 Logo


  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc