Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/shynome/doh-client
- Owner: shynome
- License: mit
- Created: 2023-08-25T16:39:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-12T16:50:47.000Z (5 months ago)
- Last Synced: 2024-08-12T19:33:01.492Z (5 months ago)
- Topics: dns, dns-over-https, doh
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## Intro
doh conn for [github.com/miekg/dns](https://github.com/miekg/dns)
```go
package mainimport (
"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)
}```