Record type APL: adjust error handling and tests #1302
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR:
Error
with the goal of making it easier to understand which conditions were being tested.Reasoning
When processing an
APL
record where the address is not on the prefix (netmask) boundary the current code will emit the errordns: invalid APL address length
and cease processing furtherdns.RR
records.dns/msg_helpers.go
Lines 795 to 798 in 1630ffe
For example, if the response includes
192.155.84.18/24
this would be an error because the correct boundary for a /24 CIDR would be192.155.84.0
instead of.18
.In my opinion this response should not be treated as a fatal processing error because:
ANY
response from being processed.While testing the changes I noticed that, in addition to the test I expected to fail, another test was now failing:
dns/msg_helpers_test.go
Lines 408 to 410 in 1630ffe
I wasn't sure what condition that test was trying to check for so I reworked the tests to check for specific
Error
s. This enabled me to ensured that the major failure paths were being tested and added a bit of clarity that some of the test names were missing.Testing / Example output
For all testing below I've used the
q
example from themaster
branch of github.com/miekg/exdns. Testing was performed withgo version go1.17 darwin/amd64
on macOS Catalina. The problem was originally noticed while running on Ubuntu 20.04 LTS.Example output - Current Code
APL
record lookup$ go run q.go --fallback @8.8.8.8 APL IN ip4.loopy.limon.baker.org ;; dns: invalid APL address length
ANY
record lookup$ go run q.go --fallback @8.8.8.8 ANY IN ip4.loopy.limon.baker.org ;; dns: invalid APL address length
Example output - PR Code
APL
record lookupANY
record lookupExample output -
dig
APL
record lookupANY
record lookup