Skip to content

Commit

Permalink
tweak readme
Browse files Browse the repository at this point in the history
  • Loading branch information
phuslu committed Oct 22, 2024
1 parent 6804d40 commit 585ec96
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[![godoc][godoc-img]][godoc]
[![release][release-img]][release]
[![goreport][goreport-img]][goreport]
[![coverage][coverage-img]][coverage]


## Features
Expand Down Expand Up @@ -92,10 +91,42 @@ func main() {
}
```

### DNS Client
### DoH Client
```go
package main

import (
"context"
"fmt"
"net/url"
"time"

"github.com/phuslu/fastdns"
)

func main() {
doh := "https://1.1.1.1/dns-query"

client := &fastdns.Client{
Addr: doh,
Dialer: &fastdns.HTTPDialer{
Endpoint: func() (u *url.URL) { u, _ = url.Parse(doh); return }(),
UserAgent: "fastdns/0.9",
Transport: http.DefaultTransport,
},
}

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()

fmt.Println(client.LookupHTTPS(ctx, "cloud.phus.lu"))
}
```

### DNS Client Tool
```bash
$ go install github.com/phuslu/fastdns/cmd/fastdig@master
$ fastdig ip.phus.lu @8.8.8.8
$ fastdig ip.phus.lu @https://1.1.1.1/dns-query

; <<>> DiG 0.0.1-Fastdns <<>> ip.phus.lu
;; global options: +cmd +noedns
Expand All @@ -116,7 +147,7 @@ phus.lu. 299 IN A 101.32.116.118
;; MSG SIZE rcvd: 58
```
### DoH Server
### DoH Server Example
```bash
$ go install github.com/phuslu/fastdns/cmd/fastdoh@master
$ fastdoh :8080
Expand Down Expand Up @@ -161,7 +192,7 @@ PASS
ok github.com/phuslu/fastdns 30.430s
```
Here is the real-world flamegraph [![flamegraph][flamegraph]][flamegraph] when fastdns reaches **1.4M QPS** on a single machine with Xeon 4216 and Intel X710.
Here is the real-world flamegraph [![flamegraph][flamegraph]][flamegraph] when fastdns server reaches **1.4M QPS** on a single machine with Xeon 4216 and Intel X710.
## Acknowledgment
This dns server is inspired by [fasthttp][fasthttp], [rawdns][rawdns] and [miekg/dns][miekg/dns].
Expand All @@ -172,8 +203,6 @@ This dns server is inspired by [fasthttp][fasthttp], [rawdns][rawdns] and [miekg
[release]: https://github.com/phuslu/fastdns/releases
[goreport-img]: https://goreportcard.com/badge/github.com/phuslu/fastdns
[goreport]: https://goreportcard.com/report/github.com/phuslu/fastdns
[coverage-img]: http://gocover.io/_badge/github.com/phuslu/fastdns
[coverage]: https://gocover.io/github.com/phuslu/fastdns
[benchmark]: https://github.com/phuslu/fastdns/actions?query=workflow%3Abenchmark
[flamegraph]: https://cdn.jsdelivr.net/gh/phuslu/fastdns/torch.svg
[fasthttp]: https://github.com/valyala/fasthttp
Expand Down

0 comments on commit 585ec96

Please sign in to comment.