Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

DNS over HTTPS (DoH) Golang implementation

License

NotificationsYou must be signed in to change notification settings

likexian/doh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LicenseGoDocGo Report CardBuild StatusCode Cover

doh-go is a DNS over HTTPS (DoH) Golang client implementation.

Overview

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.

Features

  • 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

Installation

go get -u github.com/likexian/doh

Importing

import (    "github.com/likexian/doh"    "github.com/likexian/doh/dns")

Documentation

Visit the docs onGoDoc

Example

Select fastest provider and query (Highly Recommend)

// 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)}

Specify DoH provider and query (You are Welcome)

// 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)}

Providers

Quad9 (Recommend)

Quad9 is a free, recursive, anycast DNS platform that provides end users robust security protections, high-performance, and privacy.

Cloudflare (Fast)

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 (NOT work in Mainland China)

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.

DNSPod (Work well in Mainland China)

The backend is a anycast public DNS platform well known in China.

LICENSE

Copyright 2019-2024 Li Kexian

Licensed under the Apache License 2.0

About

DONATE

About

DNS over HTTPS (DoH) Golang implementation

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp