Brian Wellington [Thu, 25 Jun 2020 00:04:59 +0000 (17:04 -0700)]
Fix TTL limiting.
The message code would convert negative TTL into 0, but the TTL could
never be negative, as it was read with the '!I' format, which reads
unsigned 32 bit integers. We don't want to change that, since OPT flags
(which are encoded in the TTL) should be treated as unsigned. Instead,
treat all TTLs > (2^31 - 1) as 0.
dependabot[bot] [Wed, 24 Jun 2020 05:43:45 +0000 (05:43 +0000)]
Update mypy requirement from ^0.781 to ^0.782
Updates the requirements on [mypy](https://github.com/python/mypy) to permit the latest version.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.781...v0.782)
Brian Wellington [Tue, 23 Jun 2020 23:46:48 +0000 (16:46 -0700)]
Add more functionality to nanonameserver.
- When no port is specified, pick the same port for UDP and TCP, so that
TCP fallback can be tested.
- Change handlers to get a single Request object instead of individual
parameters. The Request object contains the message, peer, and
connection_type previously passed, and also adds the local address and
wire format message. Additionally, it provides convenient properties
for accessing the question.
Bob Halley [Tue, 23 Jun 2020 01:07:25 +0000 (18:07 -0700)]
The cached _all_slots technique of the earlier pickle fix didn't work for
GenericRdata or for directly imported types. This fix just computes the
all slots relatively efficiently every __getstate__().
dependabot[bot] [Mon, 22 Jun 2020 05:44:40 +0000 (05:44 +0000)]
Update mypy requirement from ^0.780 to ^0.781
Updates the requirements on [mypy](https://github.com/python/mypy) to permit the latest version.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.780...v0.781)
Bob Halley [Fri, 19 Jun 2020 16:23:52 +0000 (09:23 -0700)]
Make _cmp generic for all EDNS Options. It now compares the wire formats
of two objects of the same class.
Previously we did type-specific stuff for ECSOption, but we only
checked the padded address info, not the srclen or scopelen, so
different options could compare the same. Also, it's not clear that
there's any better semantic ordering of options than the wire format,
so we will just go for simplicity and use the generic implementation.
Bob Halley [Thu, 18 Jun 2020 23:09:47 +0000 (16:09 -0700)]
Fix rdata pickling.
Coverage testing showed that while rdatas would pickle and unpickle
apparently successfully, in fact only the slots from the deepest class
in the inheritance chain would be restored. So, e.g., a restored A rdata
would have an address attribute but no rdclass or rdtype attributes,
and so things like rdata comparison would break.
This change preserves the whole set of slots, from all ancestors as
well as the object, as a dictionary.
Bob Halley [Thu, 18 Jun 2020 14:20:50 +0000 (07:20 -0700)]
Construct socket.gaierror with an errno and a string, as doing just the
errno doesn't cause the errno field in the exception to be set, and thus
our exceptions were different and less useful than the stock ones.
Adjust gethostbyaddr() to filter addresses like the system one does.
Brian Wellington [Thu, 18 Jun 2020 02:15:07 +0000 (19:15 -0700)]
Simplify renderer code.
Use context manager to avoid duplicating length checking in many places.
Change the code dealing with EDNS options to avoid lots of seeking by
not rendering directly into the file.