Previously, repr() of rdataset/rrset looked like this:
<DNS IN A rdataset>
<DNS IN TXT rdataset>
<DNS IN RRSIG rdataset>
<DNS example. IN A RRset>
<DNS example. IN TXT RRset>
<DNS example. IN RRSIG(NSEC) RRset>
With this patch, it they look like:
<DNS IN A rdataset: [<1.2.3.4>, <5.6.7.8>]>
<DNS IN TXT rdataset: [<"foo" "bar">, <"baz">]>
<DNS IN RRSIG(NSEC) rdataset: [<NSEC 1 3 3600 2020010100000020030101000000 2143 foo MxFcby9k/yvedMfQgKzhH5er0Mu/vILz 45IkskceFGgiWC...>]>
<DNS example. IN A RRset: [<1.2.3.4>, <5.6.7.8>]>
<DNS example. IN TXT RRset: [<"foo" "bar">, <"baz">]>
<DNS example. IN RRSIG(NSEC) RRset: [<NSEC 1 3 3600 2020010100000020030101000000 2143 foo MxFcby9k/yvedMfQgKzhH5er0Mu/vILz 45IkskceFGgiWC...>]>
Note that each rdata is truncated to 100 characters.
Brian Wellington [Tue, 31 Mar 2020 20:45:20 +0000 (13:45 -0700)]
Remove dns.rdata.choose_relativity().
This method changes rdata in place, so prevents rdata from becoming
immutable. There are no in-tree users, and if there are out of tree
users, they are rate and hard to find.
Brian Wellington [Fri, 20 Mar 2020 20:58:02 +0000 (13:58 -0700)]
zone.to_text() should return a string.
As part of the Python 3 conversion, the result of dns.zone.to_text()
changed from str to bytes. This was likely unintentional, as a method
with text in its name should be returning text.
Brian Wellington [Wed, 18 Mar 2020 23:44:09 +0000 (16:44 -0700)]
Add relativize_to to from_text().
When calling from_text, the zone code needs to apply the current origin
(which may or may not be the zone origin, if sub-zone $ORIGIN statements
are present), and may also want to relativize the contents to the zone
origin.
Previously, this was done by explicitly reading records as absolute, and
then relativizing them laster. With this change, the work is moved to
the tokenizer.
This gets rid of the remaining internal uses of
dns.rdata.choose_relativity(), which prevents rdata from being
immutable.
Brian Wellington [Wed, 18 Mar 2020 21:56:58 +0000 (14:56 -0700)]
Remove choose_relativity() from zone.from_xfr()
The comment states that relativize must be consistent between
dns.query.xfr() and dns.zone.from_xfr(), and the code fails if they're
not (if check_origin is True, at least). This means that the rdata is
already correctly relativized (or not).
This also adds a test of creating zones from xfrs, both relativized and
not.
Thomas Ward [Tue, 10 Mar 2020 01:29:38 +0000 (21:29 -0400)]
reverse_query: BUGFIX - ipaddr, not address!
I made a mistake in the pull req and didn't catch it (OOPS!).
`dns.reversename.from_address(address)` is what was in the code. Unfortunately, that causes a nice, fat `NameError: name 'address' is not defined` error. This fixes that.
Thomas Ward [Mon, 9 Mar 2020 21:01:00 +0000 (17:01 -0400)]
Docstrings: Update reverse_lookup docstrings
Pull docstring bits from the query function that are relevant for reverse_lookup as we're now pulling the query function's arguments in (except for rdtype and rdclass) as arguments that can be accepted.
Thomas Ward [Mon, 9 Mar 2020 20:58:11 +0000 (16:58 -0400)]
Use dns.reversename, extend reverse_lookup args
Use inbuilt dns.reversename. Extend the self.query argument bits into the reverse_lookup (tcp, source, raise_on_no_answer, source_port, lifetime), and force-define the rdtype and rdclass.
Thomas Ward [Mon, 9 Mar 2020 20:14:55 +0000 (16:14 -0400)]
Add a reverse_lookup function to Resolver.
Utilize the inbuilt ipaddress library and in-built resolver query libraries to provide a reverse_lookup function. This could make it easier for users to set up their own Resolver instances which continue to behave as stub resolvers but also more easily make PTR record lookups, which would be able to be used as a direct result.
This had been written by me as an extension of the Resolver class in my own private class (called DNSResolver, which I only use internally on a few private applications) which extended the init file to define the nameservers if not specified (default: google DNS) and then extended to add the reverse_lookup function call as well.
Feel free to reject if it doesn't make sense, but it would be a nifty function to have (because `dig` for instance has a `-x` flag you can pass which accepts an IP address and will auto-reverse it to get the in-addr.arpa lookup result from nameservers, whether they're stub resolvers or not, which is a nifty function to have here.)
Peter Olson [Sat, 29 Feb 2020 20:32:37 +0000 (12:32 -0800)]
Correct Message.is_response docstring
When testing responses, I discovered that the docstring for Message.is_response had the
comparison backwards, specifically in how the `QR` flag is checked. The documentation
was incorrectly updated in fc7db7da4284eedaa951e6acc34e6e6f94da1c64
Emanuel Moser [Mon, 30 Dec 2019 18:50:10 +0000 (19:50 +0100)]
refactoring of dnssec documentation
- replaces old comments with sphinx style comments
- adds support for sphinx.ext.todo
- since `_validate()` and `_validate_rrsig()` are only internal functions they are removed from documentation