mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 11:15:54 +03:00
[GH-ISSUE #320] Ability to create invalid records #146
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#146
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vorner on GitHub (Dec 18, 2017).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/320
Hello
I noticed it is possible to create invalid record. Eg, this compiles (and runs), but produces invalid data when serialized (claims to be A, but has too much bytes).
Does it make sense to be able to create a record with different rdata than its type? Does it make sense to create an „empty“ record? Wouldn't it be better to be able to create only valid records (directly fill them with rdata, derive the record type from the rdata, etc).
@bluejekyll commented on GitHub (Dec 18, 2017):
There was a point where I was reusing common RData (like Name) across different RecordTypes, where this would have been valid. I've since moved away from that and started explicitly using separate RData types, with single values as the actual data section of the RData type. So there should be (and I think there is now) a 1-1 relationship between RecordType and RData. We could hide RecordType entirely I think at this point. RData does have a method to get the RecordType from it.
Depends on what you mean by empty. There are cases where the
NullRData type is valid, but they are mostly edge conditions.Yes. We should definitely add some validation on the RData to restrict it to RecordType. At one point I toyed with trying to make a generic type parameter to catch this at compile time, but I don't think it's easily done without adding more intermediate types. So yes, I think we could drop RecordType from the Record constructor all together, possibly each from the Record itself, and fix locations as necessary.
@vorner commented on GitHub (Dec 18, 2017):
I meant whatever is created by the
new()constructor. Yes, there are some defaults (but why empty name, for example?).What I was thinking would be to have to pass all the information at construction time. That way it wouldn't be easy to create „broken“ ones. But maybe I'm missing some edge case.
@bluejekyll commented on GitHub (Dec 18, 2017):
Yes, I think this would be a good solution. If I were writing this today, I might opt to do that. When I wrote it originally, I don't think all the potential use cases were obvious to me at the time, so I opted for more flexibility. I'm all for restricting this more now, and requiring new Records to be created if you want to change shape...
@bluejekyll commented on GitHub (Apr 9, 2019):
This was fixed in #674