Bob Halley [Thu, 23 Jul 2020 13:33:27 +0000 (06:33 -0700)]
Improve name coverage slightly by testing the uts_46 branch in 2008 decode.
I'm not sure how useful in practice this is, as we don't offer a codec
configuration default for it, but I'm not sure you'd never do it, and the
existing code was in the wrong order.
Update cryptography requirement from ^2.6 to >=2.6,<4.0
Updates the requirements on [cryptography](https://github.com/pyca/cryptography) to permit the latest version.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/2.6...3.0)
Brian Wellington [Mon, 20 Jul 2020 19:42:59 +0000 (12:42 -0700)]
Remove duplicates in the LOC sample data.
Some of these records were duplicates, which isn't all that useful for
testing. Update some from the correct BIND sample files, and fix
others to improve coverage testing.
Brian Wellington [Fri, 17 Jul 2020 23:37:53 +0000 (16:37 -0700)]
Changes to blocking model.
Before this change, the synchronous code would check sockets for
readability or writability before doing nonblocking read or write.
This changes them to attempt the read or write first, and then block
if the operation could not complete.
This also removes the no-longer-needed getpeername() call in tcp(),
which was needed to deal with the case where an unconnected socket was
passed in; waiting for writability would block rather than immediately
return an error. By attempting the write first, we get the error
immediately.
Brian Wellington [Fri, 17 Jul 2020 22:46:04 +0000 (15:46 -0700)]
Use the selectors module.
Previously, there was code to either use select.select or select.poll,
depending on OS. This changes it to use the selectors module, using
either SelectSelector or PollSelector, but sharing code otherwise.
In some cases, the caller absolutely doesn't want word breaks. This
shouldn't be the case for any normal DNS record, but is for records that
don't have well-defined text formats, like TSIG and TKEY. Allow them to
pass 0 (or None), to indicate that no word breaks should be added.
Previously, passing either 0 or None resulted in an exception, as the
value was used directly as the step in a slice.
The existing receive_udp() methods are only usable for receiving
responses, as they require an expected destination and check that the
message is from that destination.
This change makes the expected destination (and hence the check)
optional, and returns the address that the message was received from (in
the sync case, this is only done if no destination is provided, for
backwards compatibility).
New tests are added, which required adding generic getsockname() support
to the async backends.
More DNS rcodes are assigned. Support rcode assigned before RFC7873
https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6
This also fixes several bugs; the NSEC3 code would properly avoid empty
windows, but the NSEC and CSYNC code did not. Also, none of the wire
parsing routines properly checked to see that the window number was
monotonically increasing.
Bob Halley [Thu, 2 Jul 2020 15:23:52 +0000 (08:23 -0700)]
Rework wire format processing.
Wire format data is now done via a dns.wire.Parser, which does all of the
bookkeeping and also provides convenience routines (e.g. get_uint16() or
get_name()).
If dns.tsigkeyring.from_text() creates dns.tsig.Key objects with the
default algorithm, that causes problems for code that specifies a
different algorithm. There's no good way to handle this, so change
dns.tsigkeyring.from_text() to not create dns.tsig.Key objects unless it
knows the algorithm.