- Notifications
You must be signed in to change notification settings - Fork10
DNS over HTTPS (DoH) Golang implementation
License
likexian/doh
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
doh-go is a DNS over HTTPS (DoH) Golang client implementation.
DNS over HTTPS (DoH) is a protocol for performing remote Domain Name System (DNS) resolution via the HTTPS protocol. Specification isRFC 8484 - DNS Queries over HTTPS (DoH).
This module provides a easy way to using DoH as client in golang.
- DoH client, Simple and Easy to use
- Support cloudflare, google, quad9 and dnspod
- Specify the provider you like
- Auto select fastest provider
- Enable cache is supported
- EDNS0-Client-Subnet query supported
go get -u github.com/likexian/doh
import ( "github.com/likexian/doh" "github.com/likexian/doh/dns")
Visit the docs onGoDoc
// init a contextctx,cancel:=context.WithTimeout(context.Background(),10*time.Second)defercancel()// init doh client, auto select the fastest provider base on your like// you can also use as: c := doh.Use(), it will select from all providersc:=doh.Use(doh.CloudflareProvider,doh.GoogleProvider)// do doh queryrsp,err:=c.Query(ctx,"likexian.com",dns.TypeA)iferr!=nil {panic(err)}// close the clientc.Close()// doh dns answeranswer:=rsp.Answer// print all answerfor_,a:=rangeanswer {fmt.Printf("%s -> %s\n",a.Name,a.Data)}
// init a contextctx,cancel:=context.WithTimeout(context.Background(),10*time.Second)defercancel()// init doh client, specify one providerc:=doh.New(Quad9Provider)// do doh queryrsp,err:=c.Query(ctx,"likexian.com",dns.TypeMX)iferr!=nil {panic(err)}// doh dns answeranswer:=rsp.Answer// print all answerfor_,a:=rangeanswer {fmt.Printf("%s -> %s\n",a.Name,a.Data)}
Quad9 is a free, recursive, anycast DNS platform that provides end users robust security protections, high-performance, and privacy.
Cloudflare's mission is to help build a better Internet. We're excited today to take another step toward that mission with the launch of 1.1.1.1 — the Internet's fastest, privacy-first consumer DNS service.
Google Public DNS is a recursive DNS resolver, similar to other publicly available services. We think it provides many benefits, including improved security, fast performance, and more valid results. But it is not work in mainland China.
The backend is a anycast public DNS platform well known in China.
Copyright 2019-2024 Li Kexian
Licensed under the Apache License 2.0
About
DNS over HTTPS (DoH) Golang implementation