1
0
Fork
You've already forked dns
0
forked from miekg/dns
Go DNS library
  • Go 91.2%
  • Roff 8.7%
  • Makefile 0.1%
Miek Gieben 23de80de1c Remove release.yaml entirely
...Unable to parse supported events in workflow: EOF
Signed-off-by: Miek Gieben <miek@miek.nl>
2025年12月22日 08:40:04 +01:00
.forgejo/workflows Remove release.yaml entirely 2025年12月22日 08:40:04 +01:00
cmd atomdns: adjust builddepends on forgejo config 2025年12月21日 12:28:12 +01:00
deleg Release 0.6.10 2025年12月21日 11:34:10 +01:00
dnsconf Fix tests 2025年09月06日 18:04:45 +02:00
dnshttp docs and user stories 2025年12月20日 07:42:18 +01:00
dnstest Add dnstest.NewMsg for making tests slightly shorter 2025年12月20日 11:48:22 +01:00
dnsutil (chore): run modernize 2025年12月21日 08:35:09 +01:00
internal Perf on per-arch basis 2025年12月21日 08:51:58 +01:00
pool Revert "Use *strings.Builder for the builderPool" 2025年12月14日 16:12:03 +01:00
rdata Release 0.6.10 2025年12月21日 11:34:10 +01:00
svcb Release 0.6.10 2025年12月21日 11:34:10 +01:00
testdata zonemd: sign root zone 2025年11月04日 17:38:28 +01:00
.changelog.go.tmpl typo in changelog 2025年10月03日 18:35:01 +02:00
bench_test.go Fix broken things after moving UnpackName to unpack.Name 2025年08月30日 14:11:28 +02:00
CHANGELOG.md atomdns: add way to see previous handlers 2025年12月20日 07:16:52 +01:00
ci_test.go delete correct binaries 2025年09月16日 17:18:56 +02:00
client.go Run golint-ci 2025年12月14日 08:05:05 +01:00
client_test.go docs 2025年12月06日 11:01:56 +01:00
clone_generate.go Work-in-progress commit 2025年12月12日 14:01:14 +01:00
compare_generate.go Work-in-progress commit 2025年12月12日 14:01:14 +01:00
CONTRIBUTORS First code dump 2025年08月06日 08:11:49 +02:00
COPYRIGHT Fix copyright 2025年09月04日 13:49:40 +02:00
dane.go Un-export CertificateToDANE 2025年08月16日 12:43:33 +02:00
dns.go remove generate 2025年12月13日 21:04:11 +01:00
dnssec.go Run golint-ci 2025年12月14日 08:05:05 +01:00
dnssec_keygen.go lint 2025年12月15日 15:35:22 +01:00
dnssec_keyscan.go golanglint-ci: run it again 2025年12月14日 13:36:37 +01:00
dnssec_privkey.go golanglint-ci: run it again 2025年12月14日 13:36:37 +01:00
dnssec_signer.go dns: only use one buffer for DNSSEC signatures gen/verify 2025年10月29日 10:20:41 +01:00
dnssec_test.go Make it compile and fix tests 2025年12月12日 14:33:07 +01:00
dnstest_generate.go Docs and clean up of comments 2025年10月06日 16:13:59 +02:00
dnsutil_generate.go more 2025年12月13日 19:52:08 +01:00
doc.go dns: documention typos 2025年12月17日 13:04:05 +01:00
dso_types.go dns: explain how to get tls ConnectionState from Conn() 2025年11月11日 07:19:09 +01:00
dsolen_generate.go dso: finish remaining types 2025年11月10日 06:57:44 +01:00
dsorr_generate.go Generate compare functions 2025年08月23日 09:42:16 +02:00
edns_types.go fix: Fixed EDNS0 SUBNET packing so it actually emits the address prefix bytes (based on Netmask) and aligned the option length calculation with the encoded prefix length. 2025年12月22日 11:09:48 +08:00
ednsrr_generate.go Test external RRs 2025年10月15日 14:15:07 +02:00
errors.go typos in comments 2025年12月06日 11:32:43 +01:00
generate.go builderpool 2025年12月21日 09:40:59 +01:00
go.mod acl: drop infoblox and use phemmer/go-iptrie 2025年12月16日 18:47:27 +01:00
go.sum acl: drop infoblox and use phemmer/go-iptrie 2025年12月16日 18:47:27 +01:00
headerpack.go dns: use pointer to header 2025年12月20日 15:10:54 +01:00
len_generate.go Introduce RDATA next to RR 2025年12月12日 18:06:28 +01:00
LICENSE add status to the readme 2025年08月18日 07:28:14 +02:00
listen_no_socket_options.go Reapply "udp: use static buffers" 2025年12月15日 06:59:20 +01:00
listen_socket_options.go Reapply "udp: use static buffers" 2025年12月15日 06:59:20 +01:00
Makefile.release Release 0.6.9 2025年12月21日 10:57:56 +01:00
msg.go dns: more effecient packing 2025年12月20日 20:12:59 +01:00
msg_generate.go Work-in-progress commit 2025年12月12日 14:01:14 +01:00
msg_test.go fuzz: add dnszone.Stop 2025年12月19日 18:39:48 +01:00
nsecpack.go revert some 2025年12月13日 10:52:14 +01:00
opt.go Preliminary DELEG support bits 2025年08月29日 20:51:46 +02:00
optpack.go return error 2025年09月07日 09:52:17 +02:00
pack_generate.go Unknown types can be packed/unpacked 2025年12月03日 12:52:46 +01:00
parse_generate.go More docs 2025年10月15日 15:42:23 +02:00
parse_test.go dont panic in the fuzz on wrong input 2025年12月19日 19:00:23 +01:00
rdata_generate.go Fix comments 2025年12月13日 11:20:40 +01:00
README-dev.md update README 2025年12月16日 07:33:07 +01:00
README-diff-with-v1.md update README 2025年12月16日 07:33:07 +01:00
README.md Update docs 2025年12月20日 15:39:57 +01:00
response.go dns: explain how to get tls ConnectionState from Conn() 2025年11月11日 07:19:09 +01:00
reverse.go Some lint issues 2025年10月15日 09:21:04 +02:00
router Add zerr.go 2025年09月14日 08:26:44 +02:00
rr_generate.go Test external RRs 2025年10月15日 14:15:07 +02:00
rr_test.go Finish external RR code 2025年10月16日 08:29:07 +02:00
scan.go Fix non-generated files 2025年12月12日 12:24:09 +01:00
scan_ednsrr.go fix panic in NSID parser 2025年12月01日 14:39:20 +01:00
scan_rr.go (chore): linter: last bits 2025年12月16日 15:04:14 +01:00
scan_test.go Run golint-ci 2025年12月14日 08:05:05 +01:00
serve_mux.go docs 2025年12月12日 08:08:54 +01:00
serve_mux_test.go Skip reflect perf testing by default 2025年08月17日 12:06:55 +02:00
server.go docs and user stories 2025年12月20日 07:42:18 +01:00
server_no_recvmmsg.go Revert "Make batchsize a server attribute" 2025年12月14日 16:13:21 +01:00
server_recvmmsg.go no defer here 2025年12月21日 09:45:51 +01:00
server_test.go lint 2025年12月15日 15:35:22 +01:00
sig0.go Small documentation updates 2025年10月08日 20:49:51 +02:00
sig0_signer.go More msg_helpers.go to internal/{un,}pack 2025年09月01日 20:22:45 +02:00
smimea.go Remove t from Header 2025年11月24日 16:22:48 +01:00
sort.go docs 2025年12月07日 19:08:53 +01:00
sort_rdata.go Fork pool.go off into own package: pool 2025年11月22日 08:03:34 +01:00
sort_test.go Make it compile and fix tests 2025年12月12日 14:33:07 +01:00
string.go Revert "Use *strings.Builder for the builderPool" 2025年12月14日 16:12:03 +01:00
tlsa.go Remove t from Header 2025年11月24日 16:22:48 +01:00
transfer.go golanglint-ci: run it again 2025年12月14日 13:36:37 +01:00
transfer_test.go Pull signing out of client 2025年09月02日 16:12:55 +02:00
transport.go Dial back to dial 2025年12月06日 11:04:17 +01:00
tsig.go More 2025年09月16日 10:12:08 +02:00
tsig_signer.go converted to rdata 2025年12月13日 20:31:17 +01:00
tsig_test.go Domain -> Name, and a few other things 2025年08月28日 07:09:22 +02:00
types.go Revert "Use *strings.Builder for the builderPool" 2025年12月14日 16:12:03 +01:00
types_test.go Add nxdomain example 2025年12月05日 16:10:02 +01:00
udp.go udp: optimize for IPv4, set control flags on darwin. 2025年09月15日 10:40:02 -07:00
udp_darwin.go Migrate from net.IP to netip.Addr 2025年12月10日 12:15:39 -08:00
udp_no_control.go udp: optimize for IPv4, set control flags on darwin. 2025年09月15日 10:40:02 -07:00
udp_session.go Split out dns.Session to avoid repeating 2025年09月14日 08:17:41 +02:00
udp_unix.go udp: optimize for IPv4, set control flags on darwin. 2025年09月15日 10:40:02 -07:00
version.go Release 0.6.16 2025年12月22日 08:37:09 +01:00
zclone.go edns subnet, drop "Source" from fields members 2025年12月21日 10:22:58 +01:00
zcompare.go avc back 2025年12月13日 11:06:58 +01:00
zdnstest.go Go gen + docs 2025年09月24日 13:24:39 +02:00
zdnsutil.go Release 0.6.10 2025年12月21日 11:34:10 +01:00
zdsolen.go dso: finish remaining types 2025年11月10日 06:57:44 +01:00
zdsorr.go dns: more dso types 2025年11月09日 19:43:26 +01:00
zednspack.go fix: Fixed EDNS0 SUBNET packing so it actually emits the address prefix bytes (based on Netmask) and aligned the option length calculation with the encoded prefix length. 2025年12月22日 11:09:48 +08:00
zednsrr.go Test external RRs 2025年10月15日 14:15:07 +02:00
zlen.go Introduce RDATA next to RR 2025年12月12日 18:06:28 +01:00
zmsg.go avc back 2025年12月13日 11:06:58 +01:00
zonemd.go some more 2025年12月14日 08:09:11 +01:00
zonemd_test.go Unknown types can be packed/unpacked 2025年12月03日 12:52:46 +01:00
zpack.go Unknown types can be packed/unpacked 2025年12月03日 12:52:46 +01:00
zparse.go add IPN RR 2025年11月27日 17:03:42 +01:00
zrdata.go Fix comments 2025年12月13日 11:20:40 +01:00
zrr.go add IPN RR 2025年11月27日 17:03:42 +01:00

Go Report Card Go Doc status-badge

Even more alternative approach to a DNS library (version 2)

Status

  • Fast(er); recvmmsg and pipeling suppport.
    • Since a46996c I can get ~370K (UDP) qps on my laptop (M2/Asahi Linux), also see 1766e44.
    • On my Dell XPS 17 (Intel) it is similar.
    • On Intel/AMD it is lower (~200K (UDP) qps) - yet to understand why.
    • See cmd/reflect and do a go build; make new.txt. Requires dnsperf to be installed.
  • Many more convenience functions included in dns or otherwise in dnsutils.
  • Test helper function included dnstest, ala httptest, also includes useful function for non-test code.
  • Example programs included and benchmarked in cmd, cmd/atomdns which is a full blown production ready name server.
  • Everything from https://github.com/miekg/dns should work. See README-diff-with-v1.md for the differences.

For developers please read the developer README.

Less is more.

Complete and usable DNS library. All Resource Records are supported, including the DNSSEC types. It follows a lean and mean philosophy. Server side and client side programming is supported, i.e. you can build servers and resolvers with it.

We try to keep the "main" branch as sane as possible and at the bleeding edge of standards, avoiding breaking changes wherever reasonable. But because this version is young, we allow ourselves some more headroom.

The naming of types follows the RFCs. EDNS0 types are similarly named, for instance, DHU (Ds Hash Understood). If there is a clash between an actual RR's and an EDNS0 one, the EDNS0 type will get an 'E' as prefix, e.g. EDHU. This will also be done if the RR was named later than the EDNS0 option! The same is the for DSO (DNS Stateful Operations), when clashing those types will be prefixed with a 'D'. If EDNS0 and DSO clash, EDNS0 wins. See PADDING and DPADDING as an example.

Goals

  • KISS.
  • Everything is an resource record.
    • Easy way to access RR's header and resource data (rdata).
  • Small API.
    • Package dnsutil contains functions that help programmers, but are not nessecarily in scope the the dns package.
    • Package dnstest contains functions and types that help you test, similar to the httptest package.
    • Package svcb holds all details of the SVCB/HTTPS record.
    • Pacakge deleg holds details for the DELEG record.
    • Many helper/debug functions are moved into internal packages, making the top-level much, much cleaner.
  • Fast.
    • The cmd/reflect server does ~370/300K UDP/TCP respectively on the right hardware. (As stated, unsure why other machines qps numbers are lower).

Users

A not-so-up-to-date-list-that-may-be-actually-current:

  • atomdns - included in cmd/atomdns - a high performance DNS server, based on the principles of CoreDNS, but faster and simpler.
  • dnscrypt-proxy - a flexible DNS proxy, with support for encrypted DNS protocols such as DNSCrypt v2, DOH, Anonymized DNSCrypt and ODOH.
  • DNSControl - DNSControl is an opinionated platform for seamlessly managing your DNS configuration across any number of DNS hosts, both in the cloud or in your own infrastructure.

Send pull request if you want to be listed here.

Comments

What users say:

miekg/dns is probably my favorite Go module in the open source ecosystem. It is very complete (every DNS rtype is defined) and strict (field names match the RFCs, etc). DNSControl has used miekg/dns since the first release.

Your library is a blast and I cannot thank you enough 🙏.

Features

  • UDP/TCP queries, recvmmsg(2), TCP query-pipelining, IPv4 and IPv6.
  • Fast(er).
  • RFC 1035 zone file parsing ($INCLUDE, $ORIGIN, $TTL and $GENERATE - for all record types) is supported.
  • Server side programming (mimicking the net/http package), with dns.Handle and dns.HandleFunc allowing for middleware servers.
  • Client side programming.
  • DNSSEC: signing, validating and key generation for DSA, RSA, ECDSA and Ed25519.
  • EDNS0, NSID, Cookies, etc, as pseudo RRs in the (fake) pseudo section.
  • AXFR/IXFR.
  • TSIG, SIG(0).
  • DNS over TLS (DOT): encrypted connection between client and server over TCP.
  • DNS over HTTP (DOH), see the dnshttp package.
  • Improved naming by embracing sub-packages.
  • Improved RRs, by having the rdata specified in an rdata package.
  • Examples included the cmd/ directory.
  • Escapes (\DDD and \x) in domain names is not supported (anymore) - the overhead (50-100%) was too high.

Have fun!

Miek Gieben - 2025- - miek@miek.nl

See anonymous users asking for support on why these kind of requests/issues usually get closed pretty swiftly.

Building/developing

This library uses Go modules and uses semantic versioning. Getting the code and working with the library is done via:

git clone git@codeberg.org:miekg/dns # use https if you don't have a codeberg account
cd dns
# $EDTIOR *.go

If you want to use codeberg/miekg/dns in your own project, just do a go get codeberg.org/miekg/dns@latest and import codeberg.org/miekg/dns in your Go files.

Examples

A short "how to use the API" is at the beginning of doc.go. The cmd/ directory contains a reflect example program that is used for benchmarking, and further has atomdns which is full fledged DNS server that is developed in tandem with the library.

Supported RFCs

all of them and then some

  • 103{4,5} - DNS standard
  • 1348 - NSAP record (removed the record)
  • 1982 - Serial Arithmetic
  • 1876 - LOC record
  • 1995 - IXFR
  • 1996 - DNS notify
  • 2136 - DNS Update (dynamic updates)
  • 2181 - RRset definition
  • 2537 - RSAMD5 DNS keys
  • 2065 - DNSSEC (updated in later RFCs)
  • 2671 - EDNS record
  • 2782 - SRV record
  • 2845 - TSIG record
  • 2915 - NAPTR record
  • 2929 - DNS IANA Considerations
  • 3110 - RSASHA1 DNS keys
  • 3123 - APL record
  • 3225 - DO bit (DNSSEC OK)
  • 340{1,2,3} - NAPTR record
  • 3445 - Limiting the scope of (DNS)KEY
  • 3596 - AAAA record
  • 3597 - Unknown RRs
  • 4025 - A Method for Storing IPsec Keying Material in DNS
  • 403{3,4,5} - DNSSEC
  • 4255 - SSHFP record
  • 4343 - Case insensitivity
  • 4408 - SPF record
  • 4509 - SHA256 Hash in DS
  • 4592 - Wildcards in the DNS
  • 4635 - HMAC SHA TSIG
  • 4701 - DHCID
  • 4892 - id.server
  • 5001 - NSID
  • 5155 - NSEC3 record
  • 5205 - HIP record
  • 5702 - SHA2 in the DNS
  • 5936 - AXFR
  • 5966 - TCP implementation recommendations
  • 6605 - ECDSA
  • 6672 - DNAME
  • 6725 - IANA Registry Update
  • 6742 - ILNP DNS
  • 6840 - Clarifications and Implementation Notes for DNS Security
  • 6844 - CAA record
  • 6891 - EDNS0 update
  • 6895 - DNS IANA considerations
  • 6944 - DNSSEC DNSKEY Algorithm Status
  • 6975 - Algorithm Understanding in DNSSEC
  • 7043 - EUI48/EUI64 records
  • 7314 - DNS (EDNS) EXPIRE Option
  • 7477 - CSYNC RR
  • 7828 - TCP-keepalive EDNS0 Option
  • 7553 - URI record
  • 7719 - DNS Terminology
  • 7858 - DNS over TLS: Initiation and Performance Considerations
  • 7871 - EDNS0 Client Subnet
  • 7873 - Domain Name System (DNS) Cookies
  • 8080 - EdDSA for DNSSEC
  • 8482 - Minimal Answers for ANY
  • 8484 - DOH
  • 8499 - DNS Terminology
  • 8659 - DNS Certification Authority Authorization (CAA) Resource Record
  • 8777 - DNS Reverse IP Automatic Multicast Tunneling (AMT) Discovery
  • 8914 - Extended DNS Errors
  • 8976 - Message Digest for DNS Zones (ZONEMD RR)
  • 9250 - DOQ (not implemented, waiting until Go supports QUIC)
  • 9461 - Service Binding Mapping for DNS Servers
  • 9462 - Discovery of Designated Resolvers
  • 9460 - SVCB and HTTPS Records
  • 9499 - DNS Terminology
  • 9567 - DNS Error Reporting
  • 9606 - DNS Resolver Information
  • 9660 - Zone version
  • 9859 - DSYNC RR
  • draft-ietf-compact-denial - CO bit
  • draft-ietf-deleg - DELEG RR