hello-dns/tdns
2018-04-10 10:04:49 +02:00
..
ext explain RPZ 2018-04-07 12:02:50 +02:00
.gitignore and gitignore 2018-04-02 13:25:51 +02:00
contents.cc clang adjustments 2018-04-10 10:04:49 +02:00
dns-storage.cc fix querying glue directly 2018-04-10 00:06:03 +02:00
dns-storage.hh clang adjustments 2018-04-10 10:04:49 +02:00
dns-types.cc lots of work, starting to look useful 2018-04-09 23:04:13 +02:00
dns-types.hh clang adjustments 2018-04-10 10:04:49 +02:00
dns.hh rebase 2018-04-01 18:31:41 +02:00
dnsmessages.cc lots of work, starting to look useful 2018-04-09 23:04:13 +02:00
dnsmessages.hh clang adjustments 2018-04-10 10:04:49 +02:00
Makefile clang adjustments 2018-04-10 10:04:49 +02:00
nenum.hh lots of work, starting to look useful 2018-04-09 23:04:13 +02:00
README.md fix querying glue directly 2018-04-10 00:06:03 +02:00
safearray.hh it works again 2018-04-09 20:49:37 +02:00
tdns.cc clang adjustments 2018-04-10 10:04:49 +02:00

teaching DNS

Welcome to tdns, the teaching authoritative server, implementing all of basic DNS in 1000 lines of code.

The goals of tdns are:

  • Protocol correctness
  • Suitable for educational purposes
  • Display best practices

Non-goals are:

  • Performance
  • Implementing more features

Current status

Features are complete:

  • A, AAAA, NS, MX, CNAME, TXT, SOA
  • UDP & TCP
  • AXFR
  • Wildcards
  • Delegations
  • Glue records

Missing:

  • Truncation
  • Compression (may not fit in the 1000 lines!)
  • EDNS (not 'basic' DNS by our definition, but ok)

Known broken:

  • Embedded 0s in DNS labels don't yet work
  • Case-insensitive comparison isn't 100% correct
  • RCode after one CNAME chase
  • On output (to screen) we do not escape DNS names correctly

The code is not yet in a teachable state, and the layout is somewhat confusing: some stuff is in the wrong files.

Layout

Key to a good DNS implementation is having a faithful DNS storage model. Over the decades, many many nameservers have started out with an incorrect storage model, leading to pain later on with empty non-terminals, setting the 'AA' bit on glue (or not) and eventually DNSSEC ordering problems.

When storing DNS as a tree, as described in RFC 1034, a lot of things go right "automatically".

The core or tdns therefore is the tree of nodes as intended in 1034. This is implemented in dns-storage.cc and dns-storage.hh.

This lookup mechanism will tell you if a name is fully present in a zone, or if it was matched by an NS record. It will also perform wildcard matching, but not CNAME chasing.

Best practices

The code does not do any form of DNS escaping. Instead, DNS names are stored and manipulated as a sequence of DNS labels. So instead of messing with "www.powerdns.org", we use {"www", "powerdns", "org"}.