mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 11:15:54 +03:00
[PR #1823] [CLOSED] Possibility to have AsyncClient return SerialMessages #2639
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#2639
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?
📋 Pull Request Information
Original PR: https://github.com/hickory-dns/hickory-dns/pull/1823
Author: @mattias-p
Created: 11/4/2022
Status: ❌ Closed
Base:
main← Head:generic-message📝 Commits (10+)
cee5058Extract message id from SerialMessage720ffebGeneric struct DnsResponse0afc69fGeneric type TimeoutFutured67e290Generic enum DnsResponseStreamInner9e99d30Generic struct DnsResponseStream22fc5d7Generic type MessageVerifier480d21dGeneric trait MessageFinalizer27a8aabGeneric trait DnsHandle660ac5aGeneric trait DnsRequestSender8be939dGeneric struct OneshotDnsResponse📊 Changes
19 files changed (+462 additions, -260 deletions)
View changed files
📝
bin/tests/named_tests.rs(+4 -3)📝
crates/client/src/client/async_client.rs(+108 -34)📝
crates/client/src/client/client.rs(+25 -13)📝
crates/client/src/client/client_connection.rs(+8 -3)📝
crates/client/src/lib.rs(+3 -2)📝
crates/client/src/rr/dnssec/signer.rs(+6 -4)📝
crates/client/src/rr/dnssec/tsig.rs(+11 -5)📝
crates/client/src/udp/udp_client_connection.rs(+15 -5)📝
crates/proto/src/error.rs(+7 -0)📝
crates/proto/src/op/message.rs(+8 -8)📝
crates/proto/src/udp/udp_client_stream.rs(+67 -52)📝
crates/proto/src/xfer/dns_exchange.rs(+59 -47)📝
crates/proto/src/xfer/dns_handle.rs(+5 -2)📝
crates/proto/src/xfer/dns_multiplexer.rs(+48 -34)📝
crates/proto/src/xfer/dns_response.rs(+45 -25)📝
crates/proto/src/xfer/mod.rs(+28 -19)📝
crates/proto/src/xfer/serial_message.rs(+9 -0)📝
crates/server/tests/authority_battery/dynamic_update.rs(+3 -1)📝
tests/integration-tests/tests/client_future_tests.rs(+3 -3)📄 Description
Here's a PoC for allowing AsyncClient to return responses as either Message or Vec.
The idea is to make DnsResponse and AsyncClient and everything in between generic over the response message representation so that AsyncClient can return either Messages or Vec. This PR is mostly just a big stack of commits adding a type parameter to one thing after another building up from DnsResponse to AsyncClient and adding little tweaks here and there to make things work. To start things off I made it so the response message id is extracted directly from the buffer (SerialMessage) instead of from the parsed Message - it's easy enough and we always have the buffer available in send_serial_message().
To avoid breaking lots of code I added Message as the default argument for the parameter. I don't know why this works in other places but doesn't work for AsyncClient.
I added a unit test as a quick and dirty example of usage. It probably has lots of room for improvement and it ought to be complemented with proper documentation.
When constructing an AsyncClient you have to choose between Message and Vec. Another option would be to let the caller decide for each call. This feel to me a bit like an artificial restriction, but I'm not sure what the use case would like for mixing calls for Messages and Vecs to the same AsyncClient.
I'm using
impl TryFrom<Vec<u8>> for DnsResponse<M>parsing but we need to keep the Vec around so I clone it. I've focused on getting things to work first, deferring efficiency aspects at least for now.I consistently added the type parameter to all the types themselves. In some cases it would probably better to add them to individual associated functions. For some traits maybe it's better to have them as associated types. Now that I have working code it's probably a good idea to revisit this aspect of the design.
Another thing I thought of but haven't looked into is making some deeper functions return Vec instead of DnsResponse. The potential benefit of this would be simplifying some of the type signatures. But maybe it's a terrible idea for other reasons.
I've only made things work for the AsyncClient. I haven't looked into the others.
Edit: Originally I implemented DnsResponse but I changed it to DnsResponse<Vec>. I also updated some of my reasoning in a few places.
Fixes #1814.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.