Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shynome/doh-client


https://github.com/shynome/doh-client

dns dns-over-https doh

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

## Intro

doh conn for [github.com/miekg/dns](https://github.com/miekg/dns)

```go
package main

import (
"fmt"

"github.com/miekg/dns"
"github.com/shynome/doh-client"
)

func main() {
q := dns.Question{
Name: dns.Fqdn("remoon.net"),
Qtype: dns.TypeA,
Qclass: dns.ClassINET,
}
m := &dns.Msg{
MsgHdr: dns.MsgHdr{Id: dns.Id(), Opcode: dns.OpcodeQuery, RecursionDesired: true},
Question: []dns.Question{q},
}
co := &dns.Conn{Conn: doh.NewConn(nil, nil, "1.1.1.1")}
if err := co.WriteMsg(m); err != nil {
panic(err)
}
m, err := co.ReadMsg()
if err != nil {
panic(err)
}
if len(m.Answer) == 0 {
panic("answer length must greater than 0")
}
fmt.Println(m.Answer)
}

```