{"id":13813752,"url":"https://github.com/phuslu/fastdns","last_synced_at":"2026-02-07T03:04:07.494Z","repository":{"id":42636402,"uuid":"347727387","full_name":"phuslu/fastdns","owner":"phuslu","description":"Fastest DNS package for Go","archived":false,"fork":false,"pushed_at":"2025-10-19T07:58:58.000Z","size":382,"stargazers_count":202,"open_issues_count":3,"forks_count":18,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-19T08:01:44.792Z","etag":null,"topics":["dns","dns-server","doh","doh-server"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phuslu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-03-14T19:01:08.000Z","updated_at":"2025-10-19T07:59:01.000Z","dependencies_parsed_at":"2024-03-10T05:24:26.675Z","dependency_job_id":"406b5dd6-17d4-4f6a-a17f-d6a45ddc4808","html_url":"https://github.com/phuslu/fastdns","commit_stats":null,"previous_names":[],"tags_count":72,"template":false,"template_full_name":null,"purl":"pkg:github/phuslu/fastdns","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phuslu%2Ffastdns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phuslu%2Ffastdns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phuslu%2Ffastdns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phuslu%2Ffastdns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phuslu","download_url":"https://codeload.github.com/phuslu/fastdns/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phuslu%2Ffastdns/sbom","scorecard":{"id":94206,"data":{"date":"2025-08-04","repo":{"name":"github.com/phuslu/fastdns","commit":"ff8f0bdd68b5241db44c75e0c659578413eb981d"},"scorecard":{"version":"v5.2.1-28-gc1d103a9","commit":"c1d103a9bb9f635ec7260bf9aa0699466fa4be0e"},"score":3.4,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#sast"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/benchmark.yml:1","Warn: no topLevel permission defined: .github/workflows/build.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/benchmark.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/phuslu/fastdns/benchmark.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/phuslu/fastdns/build.yml/master?enable=pin","Warn: downloadThenRun not pinned by hash: .github/workflows/build.yml:24","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 downloadThenRun dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-15T08:33:21.884Z","repository_id":42636402,"created_at":"2025-08-15T08:33:21.884Z","updated_at":"2025-08-15T08:33:21.884Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29185120,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T00:44:15.062Z","status":"online","status_checked_at":"2026-02-07T02:00:07.217Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dns","dns-server","doh","doh-server"],"created_at":"2024-08-04T04:01:28.543Z","updated_at":"2026-02-07T03:04:07.482Z","avatar_url":"https://github.com/phuslu.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Fast DNS implementation for Go\n\n[![godoc][godoc-img]][godoc]\n[![release][release-img]][release]\n[![goreport][goreport-img]][goreport]\n\n\n## Features\n\n* 0 Dependency\n* Similar Interface with net/http\n* Fast DoH Server Co-create with fasthttp\n* Fast DNS Client with rich features\n* Fast eDNS options\n* Compatible metrics with coredns\n* High Performance\n    - 0-allocs dns request parser\n    - 0-allocs dns records marshaller\n    - worker pool + message pool\n    - prefork + reuse_port + set_affinity\n\n\n## Getting Started\n\n### DNS Server\n```go\npackage main\n\nimport (\n\t\"log/slog\"\n\t\"net\"\n\t\"net/netip\"\n\t\"os\"\n\n\t\"github.com/phuslu/fastdns\"\n)\n\ntype DNSHandler struct {\n\tDebug bool\n}\n\nfunc (h *DNSHandler) ServeDNS(rw fastdns.ResponseWriter, req *fastdns.Message) {\n\tif h.Debug {\n\t\tslog.Info(\"serve dns request\", \"domain\", req.Domain, \"class\", req.Question.Class, \"type\", req.Question.Type)\n\t}\n\n\tswitch req.Question.Type {\n\tcase fastdns.TypeA:\n\t\treq.SetResponseHeader(fastdns.RcodeNoError, 1)\n\t\treq.AppendHOST1(600, netip.AddrFrom4([4]byte{8, 8, 8, 8}))\n\tcase fastdns.TypeAAAA:\n\t\tips := []netip.Addr{netip.MustParseAddr(\"2001:4860:4860::8888\")}\n\t\treq.SetResponseHeader(fastdns.RcodeNoError, uint16(len(ips)))\n\t\treq.AppendHOST(600, ips)\n\tcase fastdns.TypeCNAME:\n\t\tcnames, ips := []string{\"dns.google\"}, []netip.Addr{netip.MustParseAddr(\"8.8.8.8\")}\n\t\treq.SetResponseHeader(fastdns.RcodeNoError, uint16(len(cnames)+len(ips)))\n\t\treq.AppendCNAME(600, cnames, ips)\n\tcase fastdns.TypeSRV:\n\t\tsrvs := []net.SRV{{\"www.google.com\", 443, 1000, 1000}}\n\t\treq.SetResponseHeader(fastdns.RcodeNoError, uint16(len(srvs)))\n\t\treq.AppendSRV(600, srvs)\n\tcase fastdns.TypeNS:\n\t\tnameservers := []net.NS{{\"ns1.google.com\"}, {\"ns2.google.com\"}}\n\t\treq.SetResponseHeader(fastdns.RcodeNoError, uint16(len(nameservers)))\n\t\treq.AppendNS(600, nameservers)\n\tcase fastdns.TypeSOA:\n\t\tmname := net.NS{Host: \"ns1.google.com\"}\n\t\trname := net.NS{Host: \"dns-admin.google.com\"}\n\t\treq.SetResponseHeader(fastdns.RcodeNoError, 1)\n\t\treq.AppendSOA(600, mname, rname, 42, 900, 900, 1800, 60)\n\tcase fastdns.TypeMX:\n\t\tmxs := []net.MX{{\"mail.gmail.com\", 10}, {\"smtp.gmail.com\", 10}}\n\t\treq.SetResponseHeader(fastdns.RcodeNoError, uint16(len(mxs)))\n\t\treq.AppendMX(600, mxs)\n\tcase fastdns.TypePTR:\n\t\tptr := \"ptr.google.com\"\n\t\treq.SetResponseHeader(fastdns.RcodeNoError, 1)\n\t\treq.AppendPTR(600, ptr)\n\tcase fastdns.TypeTXT:\n\t\ttxt := \"iamatxtrecord\"\n\t\treq.SetResponseHeader(fastdns.RcodeNoError, 1)\n\t\treq.AppendTXT(600, txt)\n\tdefault:\n\t\treq.SetResponseHeader(fastdns.RcodeFormErr, 0)\n\t}\n\n\t_, _ = rw.Write(req.Raw)\n}\n\nfunc main() {\n\taddr := \":53\"\n\n\tserver := \u0026fastdns.ForkServer{\n\t\tHandler: \u0026DNSHandler{\n\t\t\tDebug: os.Getenv(\"DEBUG\") != \"\",\n\t\t},\n\t\tStats: \u0026fastdns.CoreStats{\n\t\t\tPrefix: \"coredns_\",\n\t\t\tFamily: \"1\",\n\t\t\tProto:  \"udp\",\n\t\t\tServer: \"dns://\" + addr,\n\t\t\tZone:   \".\",\n\t\t},\n\t\tErrorLog: slog.Default(),\n\t}\n\n\terr := server.ListenAndServe(addr)\n\tif err != nil {\n\t\tslog.Error(\"dnsserver serve failed\", \"error\", err)\n\t}\n}\n```\n\n### DoH/eDNS Client\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"crypto/tls\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"net/netip\"\n\t\"net/url\"\n\t\"time\"\n\n\t\"github.com/phuslu/fastdns\"\n)\n\nfunc main() {\n\tendpoint, _ := url.Parse(\"https://8.8.8.8/dns-query\")\n\n\tclient := \u0026fastdns.Client{\n\t\tAddr: endpoint.String(),\n\t\tDialer: \u0026fastdns.HTTPDialer{\n\t\t\tEndpoint:  endpoint,\n\t\t\tHeader: http.Header{\n\t\t\t\t\"content-type\": []string{\"application/dns-message\"},\n\t\t\t\t\"user-agent\":   []string{\"fastdns/1.0\"},\n\t\t\t},\n\t\t\tTransport: \u0026http.Transport{\n\t\t\t\tForceAttemptHTTP2:   true,\n\t\t\t\tMaxIdleConns:        100,\n\t\t\t\tIdleConnTimeout:     90 * time.Second,\n\t\t\t\tTLSHandshakeTimeout: 10 * time.Second,\n\t\t\t\tTLSClientConfig: \u0026tls.Config{\n\t\t\t\t\tNextProtos:         []string{\"h2\"},\n\t\t\t\t\tInsecureSkipVerify: false,\n\t\t\t\t\tServerName:         endpoint.Hostname(),\n\t\t\t\t\tClientSessionCache: tls.NewLRUClientSessionCache(1024),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)\n\tdefer cancel()\n\n\tctx = fastdns.WithClientSubnet(ctx, netip.MustParsePrefix(\"1.2.4.8/24\"))\n\n\tfmt.Println(client.LookupNetIP(ctx, \"ip4\", \"www.google.com\"))\n\tfmt.Println(client.LookupHTTPS(ctx, \"phus.lu\"))\n}\n```\n\n### DNS/eDNS Client Tool\n```bash\n$ go install github.com/phuslu/fastdns/cmd/fastdig@master\n$ fastdig www.google.com @https://8.8.8.8/dns-query +subnet=1.2.3.0/24\n\n; \u003c\u003c\u003e\u003e DiG 0.0.1-fastdns-go1.25.0 \u003c\u003c\u003e\u003e www.google.com\n;; global options: +cmd\n;; Got answer:\n;; -\u003e\u003eHEADER\u003c\u003c- opcode: QUERY, status: NOERROR, id: 589\n;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 1232\n;; QUESTION SECTION:\n;www.google.com.                IN      A\n\n;; ANSWER SECTION:\nwww.google.com. 300     IN      A       142.250.9.147\nwww.google.com. 300     IN      A       142.250.9.104\nwww.google.com. 300     IN      A       142.250.9.99\nwww.google.com. 300     IN      A       142.250.9.105\nwww.google.com. 300     IN      A       142.250.9.106\nwww.google.com. 300     IN      A       142.250.9.103\n\n;; Query time: 30 msec\n;; SERVER: https://8.8.8.8/dns-query#53(https://8.8.8.8/dns-query)\n;; WHEN: Sat Oct 11 00:44:09 +08 2025\n;; MSG SIZE  rcvd: 150\n```\n\n### DoH Server Example\n```bash\n$ go install github.com/phuslu/fastdns/cmd/fastdoh@master\n$ fastdoh :8080\n```\n\n## High Performance\n\nA Performance result as below, for daily benchmark results see [github actions][benchmark]\n```\n# go test -v -run=none -benchmem -bench=.\ngoos: linux\ngoarch: amd64\npkg: github.com/phuslu/fastdns\ncpu: AMD EPYC 7763 64-Core Processor\n\nBenchmarkMessageParseMessage-4        \t80922766\t        14.68 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkMessageEncodeDomain-4       \t100000000\t        12.78 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkMessageSetQuestion-4         \t40993672\t        30.27 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkMessageSetResponseHeader-4   \t320204428\t         3.606 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkMessageDecodeName-4          \t52074597\t        23.07 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkMessageAppendHOST-4          \t183561132\t         6.544 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkMessageAppendCNAME-4         \t42692521\t        27.77 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkMessageAppendSRV-4           \t50555230\t        23.85 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkMessageAppendNS-4            \t32065906\t        36.33 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkMessageAppendSOA-4           \t26630746\t        45.05 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkMessageAppendPTR-4           \t54242904\t        22.74 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkMessageAppendMX-4            \t61512556\t        19.59 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkMessageAppendTXT-4           \t166240762\t         7.213 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkServerHandlerHOST1-4         \t152072834\t         7.914 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkServerHandlerHOST-4          \t130878036\t         8.404 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkServerHandlerCNAME-4         \t36238018\t        33.11 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkServerHandlerSRV-4           \t47581225\t        25.69 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkServerHandlerNS-4            \t30977643\t        39.82 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkServerHandlerSOA-4           \t22182384\t        54.29 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkServerHandlerMX-4            \t42502989\t        28.91 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkServerHandlerPTR-4           \t40598533\t        28.77 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkServerHandlerTXT-4           \t100000000\t        14.72 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkServerUpdateStats-4          \t39958220\t        30.05 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkServerAppendOpenMetrics-4    \t  465868\t      2662 ns/op\t       0 B/op\t       0 allocs/op\n\nPASS\nok  \tgithub.com/phuslu/fastdns\n```\n\nHere 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.\n\n## Acknowledgment\nThis dns server is inspired by [fasthttp][fasthttp], [rawdns][rawdns] and [miekg/dns][miekg/dns].\n\n[godoc-img]: http://img.shields.io/badge/godoc-reference-blue.svg\n[godoc]: https://godoc.org/github.com/phuslu/fastdns\n[release-img]: https://img.shields.io/github/v/tag/phuslu/fastdns?label=release\n[release]: https://github.com/phuslu/fastdns/releases\n[goreport-img]: https://goreportcard.com/badge/github.com/phuslu/fastdns\n[goreport]: https://goreportcard.com/report/github.com/phuslu/fastdns\n[benchmark]: https://github.com/phuslu/fastdns/actions?query=workflow%3Abenchmark\n[flamegraph]: https://cdn.jsdelivr.net/gh/phuslu/fastdns/torch.svg\n[fasthttp]: https://github.com/valyala/fasthttp\n[rawdns]: https://github.com/cirocosta/rawdns\n[miekg/dns]: https://github.com/miekg/dns\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphuslu%2Ffastdns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphuslu%2Ffastdns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphuslu%2Ffastdns/lists"}