https://github.com/tantalor93/doh-go
DoH client written in Golang
https://github.com/tantalor93/doh-go
dns dns-client dns-over-https doh go golang golang-library rfc8484
Last synced: 5 months ago
JSON representation
DoH client written in Golang
- Host: GitHub
- URL: https://github.com/tantalor93/doh-go
- Owner: Tantalor93
- License: mit
- Created: 2021-07-31T20:47:26.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-10-27T19:12:45.000Z (over 1 year ago)
- Last Synced: 2024-10-27T23:01:57.316Z (over 1 year ago)
- Topics: dns, dns-client, dns-over-https, doh, go, golang, golang-library, rfc8484
- Language: Go
- Homepage:
- Size: 64.5 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/tantalor93/doh-go/releases)
[](https://github.com/Tantalor93/doh-go/blob/master/go.mod#L3)
[](https://godoc.org/github.com/tantalor93/doh-go/doh)
[](https://github.com/Tantalor93/doh-go/blob/main/LICENSE)
[](https://circleci.com/gh/Tantalor93/doh-go?branch=main)
[](https://github.com/Tantalor93/doh-go/actions/workflows/lint.yml)
[](https://codecov.io/gh/Tantalor93/doh-go)
[](https://goreportcard.com/report/github.com/Tantalor93/doh-go)
# doh-go
DoH client written in Golang with minimal dependencies, built on top of https://github.com/miekg/dns
and standard http client (net/http) and based on [DoH RFC](https://datatracker.ietf.org/doc/html/rfc8484#section-4.1)
## Usage in your project
add dependency
```
go get github.com/tantalor93/doh-go
```
## Examples
```
// create client with default settings resolving via CloudFlare DoH Server
c := doh.NewClient("https://1.1.1.1/dns-query")
// prepare payload
msg := dns.Msg{}
msg.SetQuestion("google.com.", dns.TypeA)
// send DNS query using HTTP POST method
r, err := c.SendViaPost(context.Background(), &msg)
if err != nil {
panic(err)
}
// do something with response
fmt.Println(dns.RcodeToString[r.Rcode])
// send DNS query using HTTP GET method
r, err = c.SendViaGet(context.Background(), &msg)
if err != nil {
panic(err)
}
// do something with response
fmt.Println(dns.RcodeToString[r.Rcode])
```